Configure GWT Tomcat Lite Instance

If you do not use Maven and are not using the GWT-Maven plugin then you can still manipulate the GWT embedded Tomcat Lite instance. You will simply need to configure things manually.

(If you DO use the plugin, which is recommended - just setup your project like the sample - then all of this is done FOR you automatically, using the Maven properties.)

First up understand that to get things working with regard to GWT and the embedded Tomcat Lite instance, with projects that require resources such as DataSources in Hosted Mode (from context.xml and web.xml), there are several ways to approach it. This way, what the plugin ultimately does, munging the embedded Tomcat configuration, is only one approach.

The MUNGE approach to configuring the Hosted Mode Tomcat Lite instance allows you to include the resources to run your project in hosted mode - these are typically a context descriptor (context.xml) a deployment descriptor (web.xml) and dependencies (JDBC drivers and so on).

Alternative techniques include using an external container instance. and or using MOCK objects while working in Hosted Mode. All of these techniques (munge, externalize, mock) are viable and have pros and cons.

Manipulating the GWT embeded Hosted Mode Tomcat instance, "Tomcat Lite."

Context.xml
1. Put context.xml where it needs to be: [PROJECT]/tomcat/conf/gwt/localhost/ROOT.xml.

Rename context.xml to ROOT.xml and place it in [PROJECT]/tomcat/conf/gwt/localhost.

Also be aware that as of today (GWT version 1.2.22) the Hosted Mode "Tomcat Lite" is Tomcat version 5.0.28. This means you need to use the long form for defining resources within context.xml (this form changed in Tomcat 5.5.x - see the sample for how it works on 5.0.x).

web.xml
2. Put web.xml where it needs to be: [PROJECT]/tomcat/webapps/ROOT/WEB-INF/web.xml.

Pretty self explanatory there, same name, goes in [PROJECT]/tomcat/webapps/ROOT/WEB-INF.

Dependencies
3. Include dependencies your setup needs ON the classpath when you start GWTShell.

The Tomcat Lite provided with GWT does not have commons-pool or commons-dbcp and so on. Whatever you need with your project needs to be supplied on the classpath when starting GWTShell. Take a look at a simple MyProject-shell script (what ApplicationCreator creates) and you will see how the shell is invoked and what is included on the classpath, edit that (or provide an env var, or so on) to manipulate the classpath as needed.

The sample includes dependencies through the plugin creating the classpath, based on the maven dependencies, before it invokes the shell (the sample will not help you if you are not using maven and the plugin).