Problem with Oracle XA-Datasource when getting the connection before starting the transaction
grischa.paul Mar 8, 2016 5:38 AMHello,
since the port of our enterprise application from EJB 2.1 to EJB 3.1 a session bean invoked periodically by an EJBTimer gets the following exception when performing database operations with an Oracle XA-datasource:
08:46:10,865 WARN [com.arjuna.ats.jta] (EJB default - 7) ARJUNA016061: TransactionImple.enlistResource - XAResource.start returned: XAException.XAER_PROTO for < formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff0a01380e:-235fbea8:56de8320:e3, node_name=1, branch_uid=0:ffff0a01380e:-235fbea8:56de8320:e5, subordinatenodename=null, eis_name=java:/Moms67DS >: oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1033) [ojdbc6.jar:11.2.0.1.0]
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:240) [ojdbc6.jar:11.2.0.1.0]
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection.start(XAManagedConnection.java:259)
at org.jboss.jca.core.tx.jbossts.XAResourceWrapperImpl.start(XAResourceWrapperImpl.java:188) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:636)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:397)
at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener$TransactionSynchronization.enlist(TxConnectionListener.java:587) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.enlist(TxConnectionListener.java:264) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.transactionStarted(TxConnectionManagerImpl.java:383) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.userTransactionStarted(CachedConnectionManagerImpl.java:207) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.tx.jbossts.UserTransactionListenerImpl.userTransactionStarted(UserTransactionListenerImpl.java:52) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.tm.usertx.UserTransactionRegistry.userTransactionStarted(UserTransactionRegistry.java:119)
at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:146)
It happens with AS 7.1 and EAP 6.0, 6.1 and 6.2. With higher versions I don't get this error.
The code just contains
Connection connection = datasource.getConnection()
ejbContext.getUserTransaction().begin();
//...perform some SQL.
ejbContext.getUserTransaction().commit();
connection.close();
When changing the order by getting the connection after starting the transaction the error does not occur.
In the EJB-spec. there is only mentioned that resources manages used after starting a transaction are enlisted, but in the examples the connections are also obtained before starting the transaction.
This is my xa-datasource:
<xa-datasource jndi-name="java:/Moms67DS" pool-name="Moms67DS" enabled="true">
<xa-datasource-property name="URL">
jdbc:oracle:thin:@localhost:1521:test
</xa-datasource-property>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<driver>com.oracle</driver>
<xa-pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
<no-tx-separate-pools>true</no-tx-separate-pools>
</xa-pool>
<security>
<user-name>moms67</user-name>
<password>moms67</password>
</security>
</xa-datasource>
And the driver:
<driver name="com.oracle" module="com.oracle">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
I use the ojdbc6.jar JDBC driver.
Any hints are welcome, thank you.