Deploy GWT sample application in Servlet container

Introduction

Since the example project provides a basic Restlet-powered server, it should be easy to deploy it inside a servlet container. GWT does not provide standard way to achieve this task, however, you can still get more information at this URL : http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=FAQ_PackageAppInWARFile.

Our sample application is composed of:

  • a client part: static page and files generated by the compilation of the org.rest.example.gwt.SimpleExample class,
  • and a server part: that serves resources called from the static page and serves the static files (via a Directory Restlet).

The main task is to generate a correct WAR file. Hopefully this is not very difficult.

Set up the WAR file

Here is the content of the target WAR file:

+ META-INF
    - MANIFEST.MF
+ WEB-INF
    - web.xml
    + lib
        - org.restlet-2.0rc3.jar: Restlet core archives
        - org.restlet.ext.servlet-2.0rc3.jar: Servlet adapter for Restlet
        - org.restlet.ext.gwt-2.0rc3.jar: Server-side integration with GWT 1.7.
        - org.restlet.ext.crypto-2.0rc3.jar: Extension that provide support of the HTTP_DIGEST challenge scheme
        - org.restlet.ext.xml-2.0rc3.jar: XML extension
        - org.restlet.ext.json-2.0rc3.jar, org.json.jar: JSON extension
        - RestletGWTSimpleExample.jar: generated by the ant script, contains the static pages and the code of the server application.

Here the content of the web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <context-param>
        <param-name>org.restlet.clients</param-name>
        <param-value>CLAP FILE WAR</param-value>
        </context-param>
    <servlet>
        <servlet-name>adapter</servlet-name>
        <servlet-class>org.restlet.ext.gwt.GwtShellServletWrapper</servlet-class>
        <init-param>
            <param-name>org.restlet.application</param-name>
            <param-value>org.restlet.example.gwt.server.TestServerApplication</param-value>
        </init-param>
        </servlet>
    <servlet-mapping>
        <servlet-name>adapter</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>