Mutant World

Sunday, November 28, 2004

Integrating JOTM 1.5.3 in Tomcat 5.0.x

Recently I have integrated Tomcat 5.0.x with JOTM 1.5.3, running on J2SE 1.4.2.

Needless to say, Greg already provides the Jetty-Extra package which already provides the Jetty-JOTM integration.

The steps for Tomcat-JOTM integration are the following:

  1. Copy to $TOMCAT/common/lib the following jars:

    • carol.jar

    • connector-1_5.jar

    • jotm.jar

    • jta-spec1_0_1.jar

    • objectweb-datasource.jar

    • xapool.jar

    I found that carol does not need any stub since it works in local mode (see below).

  2. Create a file in $TOMCAT/common/classes containing the following text:

    # lmi stands for Local Method Invocation (it's a "fake" RMI)

    # do not use CAROL JNDI wrapper

    # do not start a name server

  3. Configure Tomcat's Context (either in $TOMCAT/conf/server.xml or in $TOMCAT/conf/Catalina/localhost/<mywebapp>.xml file) so that a UserTransaction object is bound in JNDI, as shown below:

    <Context ...>
    <Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/mysql">

    <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"/>
    <ResourceParams name="UserTransaction">

    Normally there is also a DataSource configured, and this DataSource is also referenced in WEB-INF/web.xml, but that should be there independently of the transaction manager.

It is that simple.

It is very important not to include jotm.jar in WEB-INF/lib of your application.

If you want to see some extra logging to be sure everything went fine, just drop Log4J's jar into $TOMCAT/common/lib and add a in $TOMCAT/common/classes.

Jetty|Tomcat + JOTM + Hibernate does the job for me :-)


Post a Comment

<< Home