Chapter 32. Integrating Tomcat and JOnAS

Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. This guide describes how to integrate JOnAS with Tomcat from Apache (see http://jakarta.apache.org/tomcat/index.html).

Since JOnAS 2.6 provides a full J2EE application server, Tomcat can be used with JOnAS as Web container. This functionality is set up via the JOnAS web container service. At this time Tomcat 4.1.x is supported as the implementation of the JOnAS web container service. Note that in earlier versions of JOnAS a service tomcat was provided with two implementations one for Tomcat 3.3.x and one for Tomcat4.0.x. This service tomcat is now deprecated because it was not compliant to J2EE specification. So now, Tomcat 3.3.x is no longer supported with JOnAS (except through the deprecated service tomcat).

In the JOnAS J2EE server you will be able to run your beans inside EJB containers via the ejb service or ear service while you will be able to run your servlets or JSPs via the web container service or ear service.

JOnAS will be used to run your beans inside EJB containers while Tomcat will be used to run your servlets or JSPs. Inside these servlets or JSPs, you will be allowed to remotely access beans inside the JOnAS EJBServer.

For the cases where security is needed, Tomcat will be used also for user authentication. Refer to the security guide (see http://www.objectweb.org/jonas/doc/howto/SecurityExample.html) for more information on how to use security with JOnAS and Tomcat.

The following steps configure JOnAS and Tomcat to work together:

  1. Section 32.1 Configuring Tomcat for JOnAS

  2. Section 32.2 Structuring your Web Application

32.1. Configuring Tomcat for JOnAS

Since JOnAS 2.6 a new JOnAS service web is provided for launching a servlet container inside the JOnAS JVM.

At this time, a Tomcat 4.1.x implementation of this service is provided as a servlet container.

All you have to do is to add web in the jonas.services property of jonas.properties file and to set the jonas.service.web.class property of jonas.properties file to:

org.objectweb.jonas.web.catalina41.CatalinaJWebContainerServiceImpl

(It is the default value.)

Then you configure Tomcat as usual by updating if needed the $CATALINA_HOME/conf/server.xml or the $CATALINA_BASE/conf/server.xml file.

Configure Tomcat with a JOnAS realm. See Chapter 33 Example for Using Security in JOnAS with Tomcat.

If you want to customize a web application that will be deployed by the web container service or the ear service you can do this in the server.xml file by setting a <Context/> element with attribute className set to org.objectweb.jonas.web.catalina41.JOnASStandardContext

You can fiund a server.xml example in JONAS_ROOT/conf/server.xml

Of course this is only a subset of what is possible to configure in Tomcat. For more information, see Tomcat configuration documentation