Setting Up A Web Application With Jetty And Helma 1.x
Due to the recent update to Jetty 6.1 in Helma the options described in this document only apply to Helma versions <=1.6.3.
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.
Copy the two Jasper JAR files into the lib/ext directory of your Helma installation.
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"> <Arg> /manage </Arg> <Arg> ./apps/manage </Arg> </Call>
You could simply add the snippet above to the example jetty.xml 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
web.xml that needs to be stored in a special directory in
./apps/manage (according to our example) – the infamous
In the case of the manage application the full path would be
/path/to/helma/apps/manage/WEB-INF/web.xml, although it works with any other path as well as long as it is correctly defined in the second argument of
<Call name="addWebApplication"> (ie. without the
WEB-INF/web.xml part which is appended automatically).
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 (except one likes to take on Sun's official DTD). Here is a quite good one, actually written as web.xml reference guide for Tomcat.
For setting up a Helma application the very basic 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" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name> test </display-name> <servlet> <servlet-name> manage </servlet-name> <servlet-class> helma.servlet.StandaloneServletClient </servlet-class> <init-param> <param-name> application </param-name> <param-value> manage </param-value> </init-param> <init-param> <param-name> appdir </param-name> <param-value> ./apps/manage </param-value> </init-param> <init-param> <param-name> dbdir </param-name> <param-value> ./db/manage </param-value> </init-param> <!-- init-param> <param-name> cookieDomain </param-name> <param-value> .domain.tld </param-value> </init-param --> </servlet> <servlet-mapping> <servlet-name> manage </servlet-name> <url-pattern> /* </url-pattern> </servlet-mapping> </web-app>
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 (
/manage) considering the URL pattern
Thus, everything located under
/manage/* will be delegated to the manage application – making the equivalent entries in apps.properties obsolete!
Of course you might need further settings, e.g. for a static directory and the like. To get an idea how further servlet options are defined I included the setting of
cookieDomain in comments. Anything, that can be set in the initialization of the
helma.servlet.StandaloneServletClient class can be defined accordingly.
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)