How to use BTM as the transaction manager in Jetty 6.x
These instructions have been verified against BTM 1.1.
Step 1: Copy the BTM jars
Copy the following jars from the BTM distribution to the jetty6
- slf4j-jdk14.jar (or any other one available here)
Step 2: Configure BTM as the transaction manager
Copy the following into your jetty config file:
Step 3: Configure DataSources that are transaction aware
The easiest way to do this is to use the
DataSource that ship with BTM.
Here's an example of using BTM with a
DataSource that implements
javax.sql.DataSource and interacts with the
javax.sql.XADataSource provided in this instance by Derby.
If your database vendor does not provide an
XADataSource, you can use BTM's
bitronix.tm.resource.jdbc.lrc.LrcXADataSource as the
XADataSource to allow your database connections to be controlled by the transaction manager:
Again, we've used Derby as an example, but as the
LrcXADataSource uses only the class name and url of a
java.sql.Driver, you can use it with any database providing a JDBC driver.
Step 4: Configure datasources references in your web.xml
Before your code can access configured datasources via JNDI ENC URLs, you need to declare resource references in your
Now you can perform JNDI lookups on those URLs to access the configured datasources: