Saturday, May 26. 2012TomEE/OpenEJB + PostgreSQL XA DataSources
TomEE 1.0 released recently and due to that, I decided to revisit the land of EJBs once again. (Especially what is known as "EJB 3.1 Lite.") I've been a heavy Spring user both with work projects and personal projects, so EJBs have never really been on my radar. And for whatever reason, I always gravitate toward the transaction manager/database side whenever I try out a new container.
Anyway, setting up TomEE/OpenEJB with local transactions is pretty straightforward. What's problematic (and doesn't seem to be well documented at all) is setting up XA datasources. There are two major problems:
Fairly easy. And to set more properties in Definition, simply use semi-colons to delimit multiple properties. Now, to use PostgreSQL with TomEE/OpenEJB you have to first create a dummy class that extends PGXADataSource and implements javax.sql.DataSource. If you're using JDK 6/JDBC4, you will most likely have to implement a few more methods as well. For now, it seems ok if the methods simply throw UnsupportedOperationExceptions or similar, since the PostgreSQL JDBC4 classes do the same.
To solve problem #2, you can either use the PostgreSQL 8.4 driver (which doesn't have the problematic interaction with DBCP), or patch up DBCP 1.4 with the patch I attached to DBCP-356. Once that's done, the PostgreSQL XA datasource definition is pretty simple:
The only caveat is that PGXADataSource does not take a URL property, so you will have to pass the database name, server name, port, etc. as separate properties in Definition. Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
No comments
Add Comment
|
LinksSoftware projects
Public Hg Repository Public Maven Repository Project Trac Sites Calendar
QuicksearchArchives
Categories
All categories Syndicate This Blog
Blog AdministrationOpen login screen
Powered by |