Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

How to use BTM as the transaction manager in Jetty 6.x

These instructions have been verified against BTM 1.0.

Jetty 6 JNDI support

Icon

Before you can get the transaction manager via JNDI ENC (URLs starting with java:comp/), you first need to configure Jetty with support for it.
See Jetty's JNDI documentation page.

Contents

Step 1: Copy the BTM jars

Copy the following jars from the BTM distribution to the jetty6 lib/ directory:

  • btm-1.0.jar
  • geronimo-spec-jta-1.0.1B-rc4.jar
  • 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:

Hint

Icon

This will make the transaction manager available under this JNDI URL: java:comp/UserTransaction.

Step 3: Configure DataSources that are transaction aware

The easiest way to do this is to use the DataSource that ship with BTM.

ordering of XML elements

Icon

It is recommended that the datasources definitions appear before the transaction manager's one in Jetty's XML configuration. If you don't, recovery will be run on all known datasources each time a new one is created instead of just once at transaction manager's startup.

Here's an example of using BTM with a DataSource that implements javax.sql.XADataSource:

The bitronix.tm.resource.jdbc.PoolingDataSource implements javax.sql.DataSource and interacts with the javax.sql.XADataSource provided in this instance by Derby.

Hint

Icon

This datasource will be available under this JNDI URL: java:comp/env/jdbc/mydatasource.

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:

Hint

Icon

This datasource will be available under this JNDI URL: java:comp/env/jdbc/exampleNonXADS.

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.

  • No labels