Deploying GWT Applications with Jetty

I’m not a big fan of tomcat, preferring Jetty where possible. Unfortunately there are a lot of catches involved with getting GWT applications working. I’ll try to break the changes down here. This assumes that you already have a GWT project built and made with projectCreator which you are migrating into Jetty.

1) Pull the start.jar, bin/ script (which will be moved to the base of your distribution), lib and etc directories from your Jetty distribution, and put them in $DIST (your distribution directory)

2) Change your (appname)-shell script to be like the following: JettyTest-shell

APPDIR=`dirname $0`;
java -cp $CPGWT -logLevel DEBUG -noserver -port 8080 "$@" $ENTRY_POINT/$HOST_PAGE

3) Change your (appname)-compile script to look like:

APPDIR=`dirname $0`;
echo "Compiling GWT portion of application ... "
java  -cp "$APPDIR/src:$APPDIR/bin:/usr/lib/gwt/gwt-user.jar:/usr/lib/gwt/gwt-dev-linux.jar" -out "$APPDIR/webapps" "$@" net.cognitiveconsulting.gwt.JettyTest;
echo "Compiling native Java part of application ... "
ant -f net.cognitiveconsulting.gwt.JettyTest.ant.xml
echo "Moving pieces into Jetty library path ... "
( cd bin ; jar cf ../lib/net.cognitiveconsulting.gwt.JettyTest.jar * )

Remember, after this, your output directory is no longer www, it’s now “webapps”.

4) Create the directory $DIST/webapps/(appname)/WEB-INF, and create a web.xml file like this, with the definitions for your remote services:


(Please note that because wordpress ate my XML, I used a different kind of brackets, please substitute as required.)

5) Create the ant build file:
/usr/lib/gwt/projectCreator -ant net.cognitiveconsulting.gwt.JettyTest

6) Make sure you have created working servlets under the internal tomcat implementation before you proceed, making sure that the servlet information is in the .gwt.xml file in your source directory like this:

7) Make sure that a copy of $GWTDIR/gwt-servlet.jar and any other libraries you are using are installed in $DIST/lib — forget this and nothing is going to work.

8) Create an empty “logs” directory under $DIST.

You should be able to start Jetty at your convenience and browse to the (appname)/(startpage).html page. If you want to pack it as a war, just zip the (appname) directory in $DIST/webapps with a .war extension. Also, running with the parameter “supervise” will allow you to watch the logs as they go by.

Hope this has been informative and helpful.

UPDATE: Jan, one of the webtide guys, was nice enough to send me an ant build file which does much the same type of thing I was attempting to do here. It is attached here, for anyone else who would like a copy.