Discussions

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(J2EETransactionManagerOpt.java:98) at com.sun.enterprise.resource.SystemResourceManagerImpl.enlistResource(SystemResourceManagerImpl.java:69) at com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java:176) at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:258) at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:147) at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:122) at com.sun.gjc.spi.DataSource.getConnection(DataSource.java:70) ... 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(MysqlXAConnection.java:562) at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:545) at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.start(MysqlXAConnection.java:485) at com.sun.gjc.spi.XAResourceImpl.start(XAResourceImpl.java:162) at com.sun.jts.jta.TransactionState.startAssociation(TransactionState.java:258) at com.sun.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:181) at com.sun.enterprise.distributedtx.J2EETransaction.enlistResource(J2EETransaction.java:397) ... 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) http://dev.mysql.com/doc/refman/5.0/en/connector-j-versions.html 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?