Deploying Google Web ToolKit Application on Tomcat

I was doing a small proof of concepts around the capabilities that Google Web Toolkit (GWT) provides in making the user interface richer. Doing the development of an application in GWT is a breeze. I could come a small RSS feed reader POC in a matter of 7-10 days. The next step was taking care of deployment on a web server. For all concerned I am using GWT for Windows version 1.5.2 and my tomcat version is 5.5. Tomcat deployment is also explained in GWT documentation here.

If you have followed Google’s development guide instructions for creating a GWT project, you would have a project created with <AppName>-compile.cmd and <AppName>-shell.cmd. To begin the deployment process on tomcat do the following:

  • Run the <AppName>-compile.cmd. It creates the tomcat and www folders within the GWT project.
  • Create the web application folder within the TOMCAT_HOME\webapps folder. For our convinence let’s name the folder rss.
  • Copy the contents of the GWT project’s www\<GWT_Entrypoint_package>.<GWTEntryClassName> folder within the rss folder. Note .gwt-tmp folder within the www folder need not be copied.
  • Create META-INF and WEB-INF folder within the rss folder. Within WEB-INF create the folders classes and lib.
  • The tomcat folder structure within TOMCAT_HOME will appear as below:
|----webapps
|------rss
|
|
|-----WEB-INF
|--------classes
|
|--------lib
  • If you are using Eclipse with default settings, your output directory folder would be bin. Copy the contents of the bin directory into classes folder.
  • Create a web.xml within the WEB-INF folder. The XML file should have the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
	<servlet>
	      <servlet-name>DataService</servlet-name>
	      <servlet-class>com.feed.ui.gwt.server.ServiceImpl</servlet-class>
	</servlet>
	<servlet-mapping>
	      <servlet-name>DataService</servlet-name>
	      <url-pattern>/DataService</url-pattern>
   	</servlet-mapping>
</web-app>

Note my server end servlet is named ServiceImpl. This servlet will implement the RemoteServiceServlet.

  • Add all the library files your application is dependent on in the TOMCAT_HOME\webapps\rss\WEB-INF\lib folder. Also add GWT lib file gwt-servlet.jar. not add any other file like gwt-user.jar or gwt-dev-windows.jar.
  • Type in the URL http://localhost:8080/rss/<GWTEntryClassName&gt;.html
  • Start the tomcat and presto your application is up and running.
Advertisements

5 thoughts on “Deploying Google Web ToolKit Application on Tomcat

  1. Thanks for the URL, Vivek even though I believe this is more of self promotion. I have already looked at the GWT based frameworks Ext-GWT and GWT-Ext. I understand that there are licensing issues which would render using both these frameworks impossible. Refer GWT-Ext’s former project lead Sanjiv Jivan’s post(http://www.jroller.com/sjivan/entry/update_on_future_direction_of1). I understand that he is now working on developing a framework on GWT using SmartClient. That framework should be out by Nov 08.

  2. Hi,
    I am working on a POC where I want GWT to be deployed(communicate with an embedded web server ) is that possible.If so can you please provide more details on it.
    Let me know if you need any more inputs on this
    Regards
    kalavati

  3. Hi,
    With GWT 1.6, this seems to have changed pretty much. If you use GWT with eclipse, you do not even have the shell scripts any more – at least I could not find them 😉
    My main problem currently is to deploy an application with images and flash charts (from Ext-GWT). Although the basic application works if I copy the content of the /war folder to webapps, I cannot manage to make the images and flash appear. Would be grateful if anyone has an idea where the images belong…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s