How To Use JOTM as the XA Transaction Manager in Jetty6
These instructions have been tested with JOTM 2.0.10.
Step 1: Copy the jars
Assuming you have successfully downloaded JOTM, copy the following jars to jetty6's
- xapool.jar Step 2: Configure CAROL
In your jetty installation, create the file
resources/carol.properties and edit its contents to contain these lines:
Without this step, CAROL will assume control of JNDI from jetty and
java:comp/env will not be set up correctly.
Step 3: Configure the transaction manager and datasources
You need to register an XA transaction manager and XA aware DataSources. There is more information about jetty's JNDI facilities that you may find useful. Here are the snippets for your jetty config file, typically
etc/jetty.xml. In this example, we will configure a Derby JDBC driver, but of course you can substitute your own.
At this point, you have JOTM acting as the transaction manager. Now, you can define XA-aware DataSources. If you want them defined globally for all webapps within your jetty installation, you can put them inside
etc/jetty.xml. Here's one example:
Now you can hookup a
resource-ref entry for
jdbc/mydatasource and then you'll be able to do lookups in your webapp of
If instead you want to make DataSources that are restricted in scope to only a particular webapp, then you need to put the declaration in a context deployment file (ie a .xml file in $JETTY-HOME/contexts) or in a
WEB-INF/jetty-env.xml file, and you need to ensure that the org.mortbay.jetty.plus.naming.Resource declaration for the StandardXAPoolDataSource is scoped to the webapp by including as the first argument a reference to the webapp. Here's an example from a xml context deployment file:
NOTE in the example above, that the first org.mortbay.jetty.plus.naming.Resource is actually declared to be in Server scope, by the absence of a webapp reference as the first argument. It is the second org.mortbay.jetty.plus.naming.Resource (ie the one that you will lookup in your code) that uses the reference to the webapp. Ideally, both would be webapp-specific, but JOTMs internal implementation of StandardXAPoolDataSource requires being able to lookup the StandardXADataSource by absolute name, and thus it is easiest to declare that in the Server scope.