I wanted to use GWT with external application server. It is really easy to use GWT with embedded tomcat server. But, I needed advanced services provided by managed application servers like JBoss. After figuring out how to use GWT with external web servers, I am posting the details with an example web application.
I am using GWT version 1.4.1. Instructions have changed from previous releases of GWT.
I expect the following system variables are set:
Step 1: Create sample application using GWT scripts.
This will use embedded tomcat in step 1. Later on we will change it to use external web app server.
1) cd %GWT_HOME%
2) projectCreator.cmd -eclipse gwtjboss -out ..\gwtjboss
3) applicationCreator.cmd -eclipse gwtjboss -out ..\gwtjboss com.gwtjboss.client.GwtJbossTry
4) Now verify that the generated application is working with embedded tomcat using GwtJbossTry-shell.cmd
Note the URL in hosted browser http://localhost:8888/com.gwtjboss.GwtJbossTry/GwtJbossTry.html
5) Also try to bring up the hosted browser using GWT Eclipse launch configuration. It can be accessed from Run -> Debug... -> click GwtJbossTry under Java Application tree node.
Step 2: Change to use external application server
1) Run GwtJbossTry-compile.cmd script and copy the following files from 'www' output directory to %JBOSS_HOME%/server/default/deploy/gwtjboss.war
2) Update GwtJbossTry-shell.cmd.
@java -cp "%~dp0\src;%~dp0\bin;%GWT_HOME%/gwt-user.jar;%GWT_HOME%/gwt-dev-windows.jar" com.google.gwt.dev.GWTShell -noserver -port 8080 -out %JBOSS_HOME%/server/default/deploy/gwtjboss.war %* gwtjboss/com.gwtjboss.GwtJbossTry/GwtJbossTry.html
We have made the following changes to *-shell.cmd:
Added -noserver to tell GWTShell not to start embedded tomcat. Added -port 8080 because external server (JBoss here) is running on port 8080. Changed output directory to D:\jboss\server\default\deploy\gwtjboss.war so that clicking compile button in hosted browser will automatically update the deployed application. Note that in complex application, we may need complex packaging mechanism to deploy application. So this compile feature may not be very helpful in complex application. [Not necessary] Updated the path to HTML page. Go to Run -> Debug... -> click GwtJbossTry under Java Application tree node. Update arguments.
3) Now set a breakpoint inside GwtJbossTry class and play around the page. If you hit the breakpoint, you are done.
This is all we need to do to use external server.
Note the change in URL. We have added gwtjboss to URL. This is because of the fact that we have deployed the application gwtjboss.war
The directory listing of deployed application is:
The modified application is available at googlecode.
svn checkout https://gwt-external-server-jboss.googlecode.com/svn/tags/simple-gwt-jboss
or simply download gwtjboss_v01.zip
In this simple example we haven't deployed any servlet and made call to that servlet from GWT client code. Doing that is also easy. We just need to copy compiled client + server code to WEB-INF\classes, gwt-servlet.jar to WEB-INF\lib and update web.xml. More on GWT with servlet deployed in JBoss (external server) later.