HomeDocumentation > Migrating to Apache Geronimo > Migrating from Tomcat to Geronimo
{scrollbar}

Tomcat is a Web Container available with Apache product family. It implements Java Servlet 3.0 API and Java Server Pages (JSP) 2.2 API. Apache Geronimo is a Java EE6 Web profile certified application server with Apache Tomcat, Apache OpenEJB pre-integrated. As a result, while working with Geronimo you will be working with same Tomcat engine as the standalone version of Tomcat. However there are some differences which we will discuss in upcoming sections

Implementation Analysis

While working with Geronimo you will be working with same Tomcat as the standalone Tomcat. This section will enlist the basic differences/similarities between Geronimo and Tomcat

  1. Both implements servlet 3.0 and JSP 2.2 API's
  2. JNDI has to be configured manually in server.xml for Tomcat whereas in Geronimo, JNDI has access to all the object references managed by Geronimo kernel
  3. JMS is configured manually in server.xml for Tomcat whereas in Geronimo same can be achieved by GUI based Administrative Console
  4. JDBC is configured manually in server.xml for Tomcat whereas in Geronimo same can be achieved by GUI based Administrative Console
  5. web.xml is the default deployment descriptor for both servers
  6. Geronimo has container specific deployment descriptors also know as deployment plans whereas Tomcat does not have any container specific deployment descriptor

In Geronimo most of the configuration can be done using the deployment plan geronimo-web.xml, config.xml or config-substitution.properties files. Adding resources, such as JMS queues, connection factory, JDBC datasource and so on, can be easily achieved using web based Administrative console. This simplifies the configuration management versus the manual configuration done using server.xml and context.xml in Tomcat.

Best Practices

In order to overcome most migration related issues you must figure out how each service is mapped within Tomcat and applied to Apache Geronimo. The scenarios in this regard will be enlisted.

Tomcat only application

In this case you might have some servlet, JSP's added to your application. You might have also configured security realms, Tomcat specific features like JSP reloading etc.

  • Servlet and JSP's code will work equally well with Tomcat and Geronimo. So there are no modifications required on this part.
  • In Tomcat you may have configured security realms in server.xml, also an admin, manager roles can be added using tomcat-users.xml file. In Geronimo same can be achieved by adding the following tags <security-realm-name>geronimo-admin</security-realm-name> <sec:security> </sec:security> in{{ geronimo-web.xml}} (Geronimo specific deployment descriptor also known as deployment plan). Users and Groups can be added to the default realm by using the Security>Security Realm menu from the Web console.
  • In Tomcat you may have configured context level attributes for your application such as <Context cachingAllowed="true"/>. In Geronimo same can be achieved by adding the following tags <contextAttributes cachingAllowed="true"> in geronimo-web.xml. But be bewared that attributes such as className,xmlNamespaceAware,processTlds,unpackWAR,xmlValidation,path,useNaming,javaVMS,server,j2EEApplication,j2EEServer,delegate and docBase are not supported in the deployment plan because Geronimo defines those attributes explicitly or just doesn't support the attribute such as unpackWAR.

Tomcat and Apache Derby

For Tomcat to work with Apache Derby you must download Apache Derby and configure environment variables like DERBY_INSTALL, and make sure that the following jars are in the classpath:

  • lib/derby.jar
  • lib/derbytools.jar
  • lib/derbynet.jar
  • lib/derbyclient.jar
    To execute a sql command you have to use ij script which comes packaged with Apache Derby.

With regards to Apache Geronimo, you don't have to set up environment variables or classpath. This is taken care of by Geronimo. Creating database tables and database pools can be easily achieved by using web based Administrative Console. However you have to include a <dependency> </dependency> tag and <resource-ref> </resource-ref> tag in geronimo-web.xml so that the resources are visible to the deployed applications.
All the other suggestions made in Tomcat-only application section is equally valid in this scenario as well.

Tomcat and Apache AXIS

For Tomcat to work, you must include the following elements in your CLASSPATH environment variable. The jars mentioned below can be automatically downloaded within Eclipse if you have set up the development environment in Eclipse. This can be easily achieved by adding a .wsdl file in your application and using Eclipse WSDL to Java tool to generate all the required artifacts including your java classes.

  • wsdl4j-1.5.1.jar
  • saaj.jar
  • jaxrpc.jar
  • axis.jar

With regards to Apache Geronimo, you don't have to set any of the libraries mentioned above in your classpath as these are pre-integrated.

Tomcat and Apache ActiveMQ

with Tomcat, make sure you have Apache ActiveMQ installed. Include the following elements in your CLASSPATH environment variable. You must specify the JMS resources that is queue and connection factory in context.xml available with Tomcat installation using the <Resource> </Resource> tags. Next you specify the resource reference, message destination reference and message destination using <resource-ref>, <message-destination-ref>, <message-destination> tag in web.xml.

  • lib/activeio-core-3.0.0-incubator.jar
  • lib/commons-logging-1.1.jar
  • <ActiveMQ_HOME>/apache-activemq-4.1.1.jar

Start the ActiveMQ broker by running the activemq.bat script. This script can be found in <ActiveMQ_HOME>/bin

In Geronimo, connection factory and queue can be easily created using the GUI based web console. ActiveMQ is automatically started on server start. The jars mentioned are no longer required and should be removed from ClassPath. However you must include an ActiveMQ dependency using <dependency> </dependency> tags, resource references using <resource-ref> </resource-ref> tags and message destination using <message-destination> </message-destination> tags in geronimo-web.xml.

Configurations in server.xml

  1. In case you have modified ports in server.xml for your Tomcat installation and you want to achieve the same with Geronimo. This can be done by modifying config-substitution.properties available in <GERONIMO_HOME>/var/log/config-substitution.properties. PortOffset variable in config-substitution.properties can be used to modify all the ports in one go or else each port can be configured to custom values.
  2. For the rest of Tomcat specific configurations in server.xml, you can use them unchanged in Geronimo. Copy the server.xml file from Tomcat to <Geronimo_HOME>/var/Catalina directory.

Remove unneeded jars

In the case of Tomcat, you might have included various jars in your application in WEB-INF/lib. Most of these jars are already present in Geronimo and can be removed from the application. This will also reduce the size of your application to few KBs in Geronimo which would have been MBs in case of Tomcat. Also, by removing these jars, developers are no longer required to support and integrate these jars.

Do Not want to remove jars

In case you don't want to remove jars from your current environment. Maybe you want to use your version of jars and Geronimo ships a different version of jars. In that case Geronimo also provides an easy configuration. You can configure geronimo-web.xml to add <inverse-classloading/> tag. Using this tag the classloading hierarchy will change to Child First.

JSP Reloading

If you have configured Tomcat for JSP reloading, then you might want the same in Geronimo. This can be easily achieved in Geronimo by editing <geronimo_home>/var/catalina/conf/web.xml.

Search for <servlet-class>org.apache.jasper.servlet.JspServlet </servlet-class> and add the following elements under the servlet class

solidAdd the XML snippet to web.xml <init-param> <param-name>development</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>modificationTestInterval</param-name> <param-value>10</param-value> </init-param>

modificationTestInterval is time in seconds.

Persist JSP Compilation

If your Tomcat server is configured to persist JSP compilation between server restarts then you can configure Geronimo as well for the same. There are two ways you can configure this in Geronimo.

Server scoped

Using this you can retain the compiled JSPs of all Web applications running in the server across server restarts. Edit <geronimo_home>/var/catalina/conf/web.xml. Search for org.apache.jasper.servlet.JspServlet and add the following elements

solidAdd the XML snippet to web.xml <init-param> <param-name>scratchdir</param-name> <param-value> ../var/catalina/temp </param-value> </init-param> <init-param> <param-name>keepgenerated</param-name> <param-value>false</param-value> </init-param>

Create a directory <geronimo_home>/var/catalina/temp. All the web applications will be compiled and stored in temp directory. These will persist over server restarts.

Application scoped

Configure the web deployment descriptor web.xml in application as follows

solidAdd the XML snippet to web.xml <servlet> <servlet-name>jsp</servlet-name> <servlet-class> org.apache.jasper.servlet.JspServlet </servlet-class> <init-param> <param-name>development</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>fork</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>scratchdir</param-name> <param-value> ../var/catalina/temp </param-value> </init-param> <init-param> <param-name>keepgenerated</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>xpoweredBy</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>engineOptionsClass</param-name> <param-value> org.apache.geronimo.jasper.JspServletOptions </param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jspx</url-pattern> </servlet-mapping>

You need to create the <geronimo_home>/var/catalina/temp directory in this case as well.

References

Following resources can be useful while migrating from Tomcat to Geronimo
1) Learn how to use inverse-classloading - http://geronimo.apache.org/schemas-2.1/docs/geronimo-module-1.2.xsd.html. You may also want to know more on dependencies, hidden-classes, non-overridable-classes. These all elements will be helpful in modifying the geronimo-web.xml.
2) Learn how to configure JMS with apache geronimo - http://cwiki.apache.org/GMOxDOC30/web-application-for-jms-access.html
3) Learn how to configure JDBC with apache geronimo- http://cwiki.apache.org/GMOxDOC30/web-application-for-jdbc-access.html
4) For security related topics you can refer- http://cwiki.apache.org/GMOxDOC30/Administering-security.html
5) More on configuring various services- JMS, JDBC http://cwiki.apache.org/GMOxDOC30/configuring-services.html