A web.xml
file has to be created to defines a
servlet for the remote service that was defined and the mapping. The
mapping has to be the same that was used in the client when searching
the endpoint to use.
Here is an example of the xml file :
<?xml version="1.0" encoding="ISO-8859-1"> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>ServletFacadeService</servlet-name> <servlet-class>org.objectweb.easybeans.demo.sudoku.web.server.service.ServletFacadeServiceImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>ServletFacadeService</servlet-name> <url-pattern>/facade</url-pattern> </servlet-mapping> </web-app>
GWT provides some shell script to generate the client's side. It's better to use ant task.
First, a classpath needs to be defined. This classpath should include GWT libraries and the path to the source code of the Entry point :
<path id="gwt.classpath"> <pathelement location="${project.dir}/src" /> <pathelement location="${gwt.sdk.location}/gwt-user.jar" /> <pathelement location="${gwt.sdk.location}/gwt-dev-windows.jar" /> </path>
Then, code can be compiled :
<target name="compile" description="Compile demo" depends="init"> <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="on"> <classpath refid="base.classpath" /> </javac> </target>
And at the end, GWT generation can be done :
<target name="generate-gwt" depends="compile"> <java classname="com.google.gwt.dev.GWTCompiler" fork="true"> <arg value="-out" /> <arg value="${dist.www.dir}" /> <arg value="org.objectweb.easybeans.demo.sudoku.web.Sudoku" /> <classpath refid="base.classpath" /> </java> </target>
The AJAX client will be bundled in a war file and it will contains the GWT runtime library.
The war task of ant can be used to do the package :
The output generated by the GWT compiler is added at the root of
the WAR file, the libraries go in the WEB-INF/lib
folder while all classes go in
WEB-INF/classes
folder.
<target name="build.war" description="Build war file" depends="compile, generate-gwt, removejavax"> <war jarfile="${dist.webapps.dir}/sudoku.war" webxml="${resources.dir}/web.xml"> <fileset dir="${dist.www.dir}/org.objectweb.easybeans.demo.sudoku.web.Sudoku" /> <lib dir="${tmp.dir}"> <include name="gwt-user.jar" /> </lib> <classes dir="${classes.dir}"> <include name="**/**" /> </classes> </war> </target>
![]() | Warning |
---|---|
The gwt-user.jar provided by Google contains javax.servlet.* classes and then it won't be deployed on Tomcat container. These classes have to be removed. An ant target is doing this job : <target name="removejavax" depends="init"> <mkdir dir="${tmp.dir}/classes" /> <unjar src="${lib.dir}/gwt-user.jar" dest="${tmp.dir}/classes"> <patternset> <exclude name="javax/**" /> </patternset> </unjar> <jar jarfile="${tmp.dir}/gwt-user.jar"> <fileset dir="${tmp.dir}/classes" /> </jar> </target> |