users@glassfish.java.net

DataSource vs. XADataSource problem

From: <glassfish_at_javadesktop.org>
Date: Thu, 06 Mar 2008 07:00:03 PST

Hi all,

I've tried to find information about how Glassfish treats pool configurations with respect to choosing DataSource vs. XADataSource and specifying, whether connections are enlisted or not.

The problem is, I have a 3rd party library, which needs a DataSource (providing JDBC connections). This library supports XA in that it can register a Synchronization object with the transaction manager (standard API as of JTA 1.1, and it seems to work fine with Glassfish) and also it does not drive commit/rollback itself in this scenario but relies on the app server, to do that properly on the XAResource object, which is associated with the Connection, the library is working on.

I.e. the library sees only Connection instances, but never the corresponding XAResource.

However I was not able to get that configured with mySQL and Glassfish (I've wrote a tiny proxy JDBC driver to log all calls/request Glassfish does to the JDBC driver.)

I need to configure "javax.sql.DataSource" as the resource type, because this is required by the the library. Of course I need to set "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" as datasource classname, because Glassfish needs to use a XADataSource implementation.

My expected behaviour was, that Glassfish creates a proxy DataSource and drives XA on the corresponding XAResources it got from the XADataSource.

However, it does not drive XA in my scenario (maybe at best some last resource commit optimization with a fake XA wrapper around the Connection), it never calls getXAConnection.

Two additional facts:
The mySQL XADataSource implementation class unfortunately also implements DataSource (so the program/deployment does not crash); also my testcase did only use one resource. But I think (or hope) these two things do not affect how Glassfish handles XA and JDBC pools.

Any help for this?

Thank you in advance!

Christian
[Message sent by forum member 'christianr' (christianr)]

http://forums.java.net/jive/thread.jspa?messageID=262650