Whats this all about?
There are a load of places on the internet that give partial solutions to this common problem: XA Transactions, outside an application container. Here's an attempt to put them all in one place.
This uses the following technologies.
- Bitronix Transaction Manager
Selecting the correct oracle drivers
You will need to use the 126.96.36.199.0 11g drivers. These are suitable for previous versions of oracle.
Previous 10.x version of the drivers have a connetion/resource leak which will bite when you use XA.
Configuring Oracle for XA Transactions
Oracle out-of-the-box does not come configured suitable for XA transactions. You need to run the following as a SYS user.
Setting up the transaction manager
Setting up the data source
Actually that's it.
The "allowLocalTransactions" setting means that you can do stuff outside a global transaction. This isn't really recommended, but will work.
Using all this inside tests.
You must remember to destroy your application context each time you create it. Otherwise the transaction manager will grumble at being created multiple times.