Helma Logo
main list history
previous version  overview  next version

Version 2 by tobi on 20. October 2008, 14:47

Besides configuring servlets and contexts in Jetty with an XML file conforming to a special syntax proprietary to Jetty the servlet API provides a more standard approach with so-called web applications and web.xml.

This approach provides further control of defining contexts and additional features like e.g. filters. AFAIK, it was developed for easier deployment and exchange of such web applications between different server/servlet engines; but as all of this was designed for the mystical realm of the so-called Java enterprise edition (J2EE) I am only an educated boy making educated guesses.

Following are the basic steps to define a web application with Jetty and Helma 1.x.

=== Prerequisites

* *Patched Helma|http://dev.helma.org/wiki/Configuring+Jetty+in+Helma+1.x/* for running Jetty with XML configuration
* <a href="http://jetty.cvs.sourceforge.net/viewvc/\*checkout\*/jetty/Jetty/ext/jasper-runtime.jar?revision=1.13">jasper-runtime.jar</a> and <a href="http://jetty.cvs.sourceforge.net/viewvc/\*checkout\*/jetty/Jetty/ext/jasper-compiler.jar?revision=1.13">jasper-compiler.jar</a>

Copy the two Jasper JAR files into the lib/ext directory of your Helma installation.

=== Setting up jetty.xml

Before starting up Helma we need to define the web application in jetty.xml. For a start we take the manage application as example:

    <Call name="addWebApplication">

You could simply add the snippet above to the *example jetty.xml|http://dev.helma.org/wiki/Configuring+Jetty+in+Helma+1.x/* but of course it also should work with only one listener and with different settings as well.

In fact, the main configuration of the application takes place in a another XML file called <code>web.xml</code> that needs to be stored in a special directory under <code>./apps/nameOfHelmaApp</code> – the infamous <code>WEB-INF</code> directory.

In the case of the manage application this is <code>/path/to/helma/apps/manage/WEB-INF/web.xml</code>, although it works with any other path as well as long as it is correctly defined in the second argument of <code><Call name="addWebApplication"></code>.

=== Setting up web.xml

As already mentioned, web applications and their XML configuration syntax span another whole new world which I find extraordinarily hard to get adequate documentation for. Here is a quite good one, actually written as *web.xml reference guide for Tomcat|http://wiki.metawerx.net/wiki/Web.xml*.

For setting up a Helma application a very reduced configuration looks like this:

  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        <!-- init-param>
        </init-param -->

This defines the Helma manage application as a web application which will be displayed as "test" (e.g. in the list of available contexts) and which will be mounted under the context path defined in jetty.xml (<code>/manage</code>) considering the URL pattern <code>/*</code>.

Thus, everything located under <code>/manage/*</code> will be delegated to the manage application.

To get an idea how further servlet options are defined I included the setting of <code>cookieDomain</code> in comments. Anything, that can be set in the initialization of the <code>helma.servlet.EmbeddedServletClient</code> class can be defined accordingly.

=== Cave at

I noticed that everytime I start up Helma with a web application context I get an exception on shutdown:

  Exception in thread "Thread-3" java.lang.NullPointerException
at helma.util.Logging.closeAll(Logging.java:167)
at helma.util.Logging.shutdown(Logging.java:159)
at helma.main.Server.stop(Server.java:543)
at helma.main.HelmaShutdownHook.run(HelmaShutdownHook.java:36)