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>.html
- Start the tomcat and presto your application is up and running.