I am learning GWT with the guide here, http://www.gwtproject.org/gettingstarted.html
I execute:
ant build
and see all files generated in the war/ folder.
However, that's all static and frontend things.
I open the generated HTML file only to find that the ajax requests failed because there is no server serving that.
I tried putting the war/ folder in tomcat's path, and open the HTML through tomcat server, it doesn't work, either.
So where is the server side program generated by gwt and how to use them?
In production mode, only JavaScript and associated files are generated - you can use any server you want. For production, you almost certainly want more control over the server than what DevMode would provide with its built-in server (in fact, I would suggest that most teams shouldn't use the built-in server in dev mode either, except for the simplest of "Hello World" apps).
For something simple to get going and very similar to what DevMode can provide by default, check out Jetty or Tomcat, but there are many other great options as well, depending on what features you'd like to have.
Related
I am about to start working on a JSF application and I am trying to decide on how to set up my production environment.
I enjoy working off my VPS for production instead of my local host. Is there a way to launch a JSF app to my server and then build on it from there? Or is that not going to work because I have to have a compiler to compile the java each time I update?
If that is the case would it make sense to just install a compiler to the server?
This is my first JSF and real java application so if there is some good info on this please lead me there.
I have someone working with me and I was assuming if we both work of the server it would be easiest.
How would this work in a professional environment, or in other words how would a team working for a company set their environment up?
How it generally works is that each team member has a local installation, and deployments up the chain to servers are handled by the systems admin guys on requests, them being provided with an installation package containing the compiled application (a WAR or EAR file), any other files needed, and quite likely a script with database changes, an installation manual, and things like that.
You should never develop directly on a production server. Only deploy stuff there once it's complete, tested, and verified to be in working order, and secured against attacks.
As GWT translates java-code to JavaScript: is it afterwards possible to run a page without a backingserver? Like just production the html,css,js folder and just running it in a browser without a server?
Especially when using GWT with Canvas?
Absolutely, yes. If you don't have a need for a server then, well, you don't need a server.
Note: you'll have to use the xsiframe linker if you intend to serve the files from disk rather than HTTP. In most browsers the std linker (the default linker) won't work with file:// URLs.
I was looking for similar problems and, of course, there exists many but I would like to know if someone uses a similar project like us and how you have deal with it.
We are working on a project where:
- Client side is completely based on JavaScript, with Dojo Toolkit framework, which makes AJAX request to our server side.
- Server side based on Java+Spring+Hibernate which implements some REST API.
We are managin the two parts as different projects, that is, for the server side we are using maven and for each change our CI server runs tests.
The important step here is we can configura maven with profiles so the CI can create a package ready for pre-production or production environments using different property files.
The client side is a bunch (with a nice structure) of HTML, CSS and JavaScript files. Like the server side, on the client side we have property file to point the client to the right place (like the development server side).
The question is: which could be the best way on this scenario to automate the client side?development? I mean, run JavaScript tests on CI and autodeploy to the right environment using the appropriate property file.
Thanks.
While someone gives you a proper and complete answer you might want to have a look at a similar question I did. Javascript web app and Java server, build all in Maven or use Grunt for web app?
I am trying different options out there but most probably we will finish using Grunt for the client side. Maven exec to call it and build everything (client + server) with different profiles.
I have some deployment model question for a Java EE web application. Currently we are deploying our web application as a WAR file in Tomcat 6. All the content is packaged with the WAR file including the static content like images, static html pages and so on. But i want to deploy these static content in a HTTP server and use the Application server only for retrieving the dynamic content. How do i split these things? Does any one has done any thing of this sort and have a good deployment model for my scenario. Help will be appreciated.
Is it a good idea to make 2 WAR files one with only static content and deploy that WAR in HTTP server and the rest as a different WAR file and deploy it in the Application server? But this approach will have impact on all the pages where the static content is currently referred and requires code changes which is very cumbersome since our project is Huge and the code based is very very big.
Any strategy and ideas are welcome.
This can be something interesting to do for performance reasons.
You should have separate deployment scripts / deployment files to do this.
Having multiple file/WAR/folder/scripts to deploy for one project is not an issue. We have the same thing when you have to deploy your WAR and to update your database.
I would have a WAR file and a folder with your static content to deploy.
Edit
Deploying the static content in a HTTP server depends on the server.
If you want to use Apache on a Linux server, you have to set up a Virtual Host.
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
DocumentRoot /www/domain
</VirtualHost>
In this example, you have the a virtual host that listens on 80 port, for any IP address and for the server name www.example.com. Then this is redirected to the /www/domain path.
You will find much more examples and configuration options in the documentation.
You can not deploy WAR file into HTTP server. A WAR is used for Java web applications it must be deployed into application server or servlet container (like Tomcat). I don't think that its a good idea to separate static content in a separate web application. If this is one project it should be one web application, besides:
A WAR file has a special folder structure and contains special files
in addition to JSP pages, Java servlets, Java classes, HTML pages etc.
which combined forms a Web Application.
You can hold your static contents in your one application and there is really nothing bad about it.
If your project is very huge and has a lot of files it is no problem, you just need to use the project structure like that, that it should be easily understandable and readable and the application server or servlet container will take care of deploying as many contents as there is.
Up to version 4, Tomcat has been quite slow in serving static content. This is why it was frequently recommended to split dynamic from static content and serve the latter using a regular web server (the book you mentioned was issued in 2002...). Recent Tomcat versions do not face this problem, thus you can IMHO refrain from splitting, which can be a nightmare for both organization and security.
For static resources, you might rather focus on configuring proper caching, so they will not be transferred more often than necessary.
I've read some articles on the Internet that this is not possible. To communicate own SQL database that is located on other server from GWT application. Jetty doesn't allow it.
I found a way how to perform it but it's not very cosy. I have client and server part inside GWT. The server has to communicate with MySQL database on localhost. So I've written an ant script to build a war that I can launch on Apache Tomcat server. It works perfectly there but I'm not able to debug the code effectively.
Do you have some advices how to perform this task? I was thinking of writing the clienty only in GWT and find some waz how to communicate my own server written outside the GWT. I've found Apache Thrift for GWT but this edited library of thrift seem not to work properly.
Thank you very much for your answers:)
It is possible to communicate with a database from a GWT application. The client side has to call the methods of the server via GWT-RPC, which can communicate with any database.
Maybe Jetty does not support it (have not tested it personally) but you can develop your web application using Apache too. There you can access the database the same way as from any web application:
You will need the mysql-connector-java-5.1.20-bin.jar file (downloadable from: http://dev.mysql.com/downloads/connector/j/ ), and restart the server added to the $CATALINA_HOME/common/lib directory.
OR added to the WEB-INF/lib folder of your web application.
You can find tutorials online of how to develop an application using Tomcat instead of Jetty. For example: https://wiki.auckland.ac.nz/display/BeSTGRID/Deploying+GWT+to+Tomcat+in+Eclipse
Reshi, stop and think about how applications really work. Nobody provides web pages with javascript to read/write databases, that would be crazy and unsecure. Servers are always in themiddle of all communication in this case. You need to create services that run inside your server, one of these services will be a database layer.
Javascript cant create network connections and read/write binary data, thus it would be insane to attempt to get the gwt compiler to compile any jdbc drvier and more.
Jetty does NOT stop us from connecting to a database. All you have to do is to follow the MVP model way. Although MVP is better bet against all hurdles, at a minimal point, you would have to try not having SQL code on the client package.