DIY & Music & Guitar & Beer & Tech

SuperDevMode GWT 2.7 running on External Tomcat Server

This is an update on previous post on SDM. Build-in Jetty server in eclipse (coming bundled with the Google-plugin) has never really been a reliable partner for developing as it often differs from the real production environment. SuperDevMode enables debugging in the browser (no network trip and Java emulation) which is nice and it can be easily used together with a ‘real’ web-application server (either with newer version of jetty or tomcat or any other container). For instance here is setup for running SDM (from eclipse) and serving backend from tomcat 7.

First, we need tomcat7 maven plugin, we add this in pom.xml:

<plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version><configuration><path>/</path><!-- leave it empty or add any known subdomain that is going to be used in production e.g. /web/ --></configuration></plugin>

now we can start backend anytime by simply navigating to the project folder and run:

mvn tomcat7:run

Before we run it, make sure it’s built properly, run (only once actually, this is mainly to compile GWT stuff, Java will be re-compiled whenever we restart Tomcat):

mvn clean package

Also, GWT-compile your project (i.e. from eclipse) just once before you fire it everything (right-click on project->Google->GWT Compile). After this step, project will be compiled incrementally as you go.
Once server is running (perhaps on localhost:8080/), go to eclipse and create new run configuration for SDM. I will skip details on this as it’s assumed that it is familiar to the developer. However few details I will mention here:

* In ‘Server’ tab, un-check “Run built-in server”
* In ‘GWT’ tab, in section ‘Browsers’ use URL like: ‘http://localhost:8080/’
* In ‘Arguments’ tab, change path to -war {whatever-actual-path-to-project}srcmainwebapp (this is only needed if multi-module, multi environment build. If the build execution is simple war, one can run it from the target map as well)

Run the Tomcat, run the SDM, navigate to localhost:8080, the Tomcat will serve site (all JSP/JSF/Servlets will be processed as they would normally). Depending on your (assumed) login logic, you might navigate to localhost:8080/YOUR-GWT-FILE.html manually (or go directly to it if you do authentication from GWT – but seriously, don’t do that:) ).

That’s it. Backend can be restarted (as SDM as well) completely independent of each other, server and client side can be debugged/developed separately and all is good.