Setting XA DataSource on Sun Java Appliation Server 8.1 enterpri


EJB programming & troubleshooting: Setting XA DataSource on Sun Java Appliation Server 8.1 enterpri

  1. Hi everyone, I am developing a J2EE application that requires to query data from 2 different MySQL catalogs using CMP EJB. I am using MySQL JDBC Connector/J 5.0.4 (currently latest), and deployment server is Sun Java Appliation Server 8.1 enterprise edition.Everything worked perfectly till I started to query both datasources in a single transaction. For a case when both datasources are configured as follows: Resource Type: javax.sql.XADataSource DataSource Classname: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource I get the following exeption: [#|2007-01-18T13:21:41.445+0100|SEVERE|sun-appserver-ee8.1|javax.enterprise.resource.resourceadapter|_ThreadID=15;|RAR5027:Unexpected exception in resource pooling java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources. at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.enlistResource( at com.sun.enterprise.resource.SystemResourceManagerImpl.enlistResource( at com.sun.enterprise.resource.PoolManagerImpl.getResource( at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection( at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection( at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection( at com.sun.gjc.spi.DataSource.getConnection( ... If I change DataSource Classname to "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" I get the following exeption as soon as I deploy application: [#|2007-01-18T12:23:47.151+0100|WARNING|sun-appserver-ee8.1|javax.enterprise.system.core.transaction|_ThreadID=12;|JTS5041: The resource manager is doing work outside a global transaction com.mysql.jdbc.jdbc2.optional.MysqlXAException: XAER_OUTSIDE: Some work is done outside global transaction at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.mapXAExceptionFromSQLException( at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.dispatchCommand( at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.start( at com.sun.gjc.spi.XAResourceImpl.start( at com.sun.jts.jta.TransactionState.startAssociation( at com.sun.jts.jta.TransactionImpl.enlistResource( at com.sun.enterprise.distributedtx.J2EETransaction.enlistResource( ... The tricky part is that the method that involves both datasources is actualy ejbTimeout and it has "RequiresNew" transaction option. Any help is appriciated. I can provide more info if necessary. Thanks in advance Amir
  2. Check the driver class. It must be XA compliant. It is a frequent issue for developers.
  3. Try using datasource class name as "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"
  4. I think this is the MySQL JDBC driver bug. They claim that the 5.0 version of JDBC driver supports distributed transactions (XA) However it is not tested on Sun AS. Is there anyone who succeeded to execute distributed transaction on Sun Java Appliation Server 8.1 enterprise with MySQL database?