Tomcat 6 Integration with Atomikos 3.2 or older

It is possible to fully integrate the Atomikos transaction manager into Tomcat. Doing it this way makes the transaction manager shared across all web applications exactly like with any full-blown J2EE server.

Important note

When the Atomikos transaction manager is installed globally in Tomcat, you now must also install your JDBC driver at the same global location (ie: into the TOMCAT_HOME/lib folder). If you dont do that, you will get a NoClassDefFoundErrors or a ClassNotFoundException or even a ClassCastException during your web application deployment.

This is not a limitation of Atomikos nor of Tomcat but of the J2EE class loading design that both Tomcat and Atomikos must follow.

Installation

Installation is quite simple, it just involves copying some JAR files, a property file and editing some Tomcat configuration files.

Copying Atomikos Tomcat Lifecycle library

This JAR contains a single class file that is a Tomcat lifecycle listener: it listens for Tomcat's startup and shutdown events and start or stop the transaction manager accordingly. Here is its source code: