Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
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 13 Next »

How to use Atomikos as the transaction manager in jetty6

These instructions are for Atomikos 3.3 onwards, and have been verified against Atomikos 3.4.2. If you are using an older version, see #Configuration for older versions for additional instructions (for Atomikos versions 2.10, 3.0.1).

Step 1: Copy the Atomikos jars

Copy the following jars from your Atomikos installation to the jetty6 lib directory:

Atomikos 3.3.x onwards
  • transactions-essentials-all.jar
  • jta.jar

Step 2: Configure Atomikos as the transaction manager

Copy the following into your jetty config file:

Atomikos 3.x

Step 3: Configure DataSources that are transaction aware

The easiest way to do this is to use the DataSources that ship with Atomikos. Atomikos provides two different flavours of DataSource. One is for use with database datasources that are XADataSource compliant (ie they fully participate in two phase commits), and another which allows non-XA aware datasources to nevertheless work with the transaction manager (however some XA features such as pending transaction recovery will not be available).

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

Atomikos 3.3.x

The com.atomikos.jdbc.AtomikosDataSourceBean 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 Atomikos's com.atomikos.jdbc.nonxa.NonXADataSourceBean to allow your database connections to be controlled by the transaction manager:

Again, we've used Derby as an example, but as the NonXADataSourceBean uses only the class name and url of a java.sql.Driver, you can use it with any database providing a JDBC driver.

There is more documentation available from the Atomikos site on using their DataSources.

Configuration for older versions

The sample configurations in this section have been verified against Atomikos 2.10 and 3.0.1, and are provided for legacy purposes. Updated code and more detailed explanations of each section are available above.

Step 1: Copy the Atomikos jars

Copy the following jars from your Atomikos installation to the jetty6 lib directory:

Atomikos 2.10
  • transactions_2_10.jar
  • jta.jar
  • licenseJTA.jar
Atomikos 3.0.1
  • transactions.jar
  • jta.jar
  • transactions-jta.jar
  • transactions-api.jar
  • atomikos-utils.jar

Step 2: Copy and install the Atomikos console webapp

Icon

Skip this step for Atomikos 3.0.1 and higher

Copy the following webapp to a jetty6 deployment directory, for example webapps-plus:

  • appservers/other/atomikos.war

If you are using the etc/jetty-plus.xml configuration file and you are deploying from webapps-plus you won't need to configure the webapp for jetty6, as the etc/jetty-plus.xml file automatically deploys everything in webapps-plus. If you are doing something different, you can use the following xml snippet to configure the Atomikos console webapp for jetty6:

Don't forget to substitute MY/DEPLOY/DIRECTORY with the location of your deploy directory.

Step 3: Configure Atomikos as the transaction manager

Copy the following into your jetty config file:

Atomikos 2.10
Atomikos 3.0.1

Step 4: Configure DataSources that are transaction aware

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

Note that com.atomikos.jdbc.SimpleDataSourceBean has been deprecated in favor of com.atomikos.jdbc.AtomikosDataSourceBean since 3.3.x. com.atomikos.jdbc.SimpleDataSourceBean takes a semi-colon delimited string of attribute pairs, while com.atomikos.jdbc.AtomikosDataSourceBean accepts java.util.Properties.

If your database vendor does not provide an XADataSource, you can use Atomikos's com.atomikos.jdbc.nonxa.NonXADataSourceBean to allow your database connections to be controlled by the transaction manager. For an example of this, see Configure DataSources that are transaction aware (same as recent versions of Atomikos).

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery