how to deploy gwt apps to tomcat

4,500 views
Skip to first unread message

Freak.2k

unread,
Aug 9, 2006, 12:09:05 PM8/9/06
to Google Web Toolkit
Hello,

how do I deploy my gwt application to the tomcat server?
found nothing...

greetz from germany

ash

unread,
Aug 9, 2006, 7:09:05 PM8/9/06
to Google Web Toolkit
mate,

if your question is how to i build a non-trivial gwt web application
archive (ie. war) that can be deployed into tomcat then consider
looking at:
1. (from http://juls.googlecode.com/svn/trunk/build.xml)

<target name="build" depends="compile, compileJs">
<antcall target="buildLibs" />
<antcall target="buildWar" />
</target>

<target name="buildWar" depends="buildLibs">
<antcall target="cleanDebug" />
<mkdir dir="${milestone.dir}" />

<copy todir="${build.dir}/tmp.web-inf-lib" flatten="true">
<fileset dir="${cm-assemblies.lib.dir}"
excludes="**/*-javadocs.jar">
<include name="gems-gwt-user/gems-gwt-rpc-1.0.21.jar"/>
<include name="gems/gems-svc-api.jar"/>
<include name="gems/gems-server.jar"/>
<include name="log4j/log4j-1.2.8.jar"/>
<include name="commons-fileupload/commons-fileupload-1.1-RC2.jar"/>
<include name="commons-io/commons-io-1.2.jar"/>
<include name="commons-lang/commons-lang-2.1-RC8.jar"/>
</fileset>
</copy>

<war warfile="${milestone.dir}/${war.name}" webxml="${web.xml}">
<fileset dir="${webapp.dir}" />
<lib dir="${build.dir}/tmp.web-inf-lib" />
<lib dir="${libs.dir}" />
</war>
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${build.dir}/tmp.web-inf-lib" />
</delete>
</target>

<target name="compileJs" depends="compile, cleanForJs">
<copy todir="${webapp.dir}/${gwt-xml-ep.name}">
<fileset dir="${gem-appl-public.dir}" includes="**/*"/>
</copy>
<java classpathref="js.build.classpath"
classname="com.google.gwt.dev.GWTCompiler"
fork="true">
<arg value="-out"/>
<arg value="${webapp.dir}"/>
<arg value="${gwt-xml-ep.name}"/>
<!--
Every now and then you will need uncomment the following to be
able
to debug FF in Venkman to remove a gwt-user-lib bug that only
manifests itself in non IE browsers.
<arg value="-style"/>
<arg value="DETAILED"/>
-->
</java>
<move todir="${webapp.dir}">
<fileset dir="${webapp.dir}/${gwt-xml-ep.name}">
<include name="jump.css"/>
<include name="images/**" />
</fileset>
</move>
</target>


alternatively, if your question is how to i deploy a jee application
into tomcat, then tomcat versions will play a roll here. i have two
examples based on tomcat 5.5.9 release:

approach 1.
1. first take a look at my server.xml. u will notice that there is
bugger all in here:
http://juls.googlecode.com/svn/trunk/dist/jakarta-tomcat-5.5.9/conf/server.xml
2. i mounted my application into tomcat's root context. that means my
application does not need a root context to get signalled. Take a look
at my ROOT.xml:
http://juls.googlecode.com/svn/trunk/dist/jakarta-tomcat-5.5.9/conf/Catalina/localhost/ROOT.xml

you will notice that my non-debug context has the following docBase
value: docBase="${catalina.home}/../bin/juls.war"
this means that on tomcat boot, it will extract juls.war from the
specified location into tomcat's ${catalina.home}/webapps folder if it
as not already been extracted


approach 2.
If i change the docBase value (which i do to debug the server code) to
docBase="${catalina.home}/../../webapp", then it will use my source
rather than a built package.

rgds ash
http://www.gworks.com.au/

self help sources:
1. http://javaongems.org/ -> http://code.google.com/p/javaongems/
2. http://code.google.com/p/gems-gwt-user/
3. http://code.google.com/p/juls/

Freak.2k

unread,
Aug 10, 2006, 1:53:33 AM8/10/06
to Google Web Toolkit
thanks...
this sounds a bit difficult....
but whats the default way to deploy gwt applications?

jsaar

unread,
Aug 10, 2006, 6:04:54 AM8/10/06
to Google Web Toolkit
in a nutshell:

Normally there are 2 parts:

- client-part
- server-part

I think in most cases tomcat is used as webserver.
there the root for deploying is in:

<path-to-tomcat-host>/webapps/<application-dir>/

there should be a dir for the html/js things ... let us call it
"hellogwt"
so you get the following structure

./hellogwt
./WEB_INF
./WEB_INF/lib
./WEB_INF/classes

where lib and classes are the places for all that is needed for the
Servlet

All that should be put into file <application-dir>.war
and this file should be copied to the webapps-dir.

A Tomcat with an enhanced management can be found at:
http://centaurus.sourceforge.net/home.html

Centaurus-Platform makes tomcat very much easyier ...

Scott Blum

unread,
Aug 13, 2006, 12:27:13 PM8/13/06
to Google-We...@googlegroups.com
Hi Freak.2k,

Probably the easiest way to describe it is with an example.  I've attached a WARed DynaTable from 1.1.0.

If the attachment doesn't come through on the group, here is a listing of the contents:

6F6A5A9C0EDF42E8688A1AC27524F2C9.cache.html
6F6A5A9C0EDF42E8688A1AC27524F2C9.cache.xml
A5E915C34D8C45AFDB60EFAF90493A8A.cache.html
A5E915C34D8C45AFDB60EFAF90493A8A.cache.xml
AC539BDC02597A92D78FB2AA82370482.cache.html
AC539BDC02597A92D78FB2AA82370482.cache.xml
com.google.gwt.sample.dynatable.DynaTable.nocache.html
DynaTable.css
DynaTable.html
E35E3C7B95E0E54D5DFDB4856FA435FF.cache.html
E35E3C7B95E0E54D5DFDB4856FA435FF.cache.xml
gwt.js
history.html
tree_closed.gif
tree_open.gif
tree_white.gif
WEB-INF/
WEB-INF/lib/
WEB-INF/lib/DynaTable.jar
WEB-INF/lib/gwt-servlet.jar
WEB-INF/web.xml

All the stuff in the top level directory is simply the compiler output folder.  WEB-INF/lib contains gwt-servlet.jar and a DynaTable.jar produced by running a DynaTable.ant.xml produced by projectCreator.  Here's the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
        <servlet>
                <servlet-name>SchoolCalendarService</servlet-name>
                <servlet-class>com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>SchoolCalendarService</servlet-name>
                <url-pattern>/calendar</url-pattern>
        </servlet-mapping>
</web-app>

Finally, I made two minor tweaks to the DynaTable source code:

SchoolCalendarWidget(39): target.setServiceEntryPoint(GWT.getModuleBaseURL() + "calendar");
DynaTable.gwt.xml(3): <servlet path='/calendar' class=' com.google.gwt.sample.dynatable.server.SchoolCalendarServiceImpl'/>

The serviceEntryPoint change is necessary to get the path correct when deployed to Tomcat, and the gwt.xml change makes hosted mode work correctly with the entry point change.

Hope this helps,
Scott
DynaTable.war

sharad sinha

unread,
Aug 13, 2006, 2:04:52 PM8/13/06
to Google Web Toolkit
Hi Freak,

If i undestood properly, These are the basic primitive steps needed to
get ur GWT app runnng on a stand-alone Tomcat.

1. Put the gwt released jars in ur project classpath. Compile ur
project and copy the classes to tomcat WEB-INF / classes folder.
2. Run <urAppName>-compile.cmd file, it will generate the javascript
from ur java source, needed to be deployed in tomcat.
Obviously this cmd file should contain the proper path of ur
project src, classes and all the referenced jars including gwt jars.
3. This cmd file emits lots of .cache, html and xml files in www /
xyz.123.bla.bla.html folder (ur module name).Copy all these files
in tomcat parallel to WEB-INF directory. Map ur servlet in web.xml
file, this mapping should coincide with service entry point u
have specified in ur gwt app rpc calls to the servlet.
4. Now start ur tomcat and run ur application like a normal web
application. Its done.

Reply all
Reply to author
Forward
0 new messages