« Return to Thread: OracleXAResource.disallowLocalTxnMode exception with Bitronix

Re: OracleXAResource.disallowLocalTxnMode exception with Bitronix

by Ludovic Orban-2 :: Rate this Message:

| View in Thread

The exception looks like you're running into the classic Oracle bug which prevents mixing local and xa transactions on the same connection.

The problem is that the problem doesn't match your sample code and the stack trace doesn't match the JDBC driver version you posted.

I'd recommend you to retry from a clean environment and to set allowLocalTransactions to false to make sure local transactions will never be used.


On Fri, Apr 13, 2012 at 8:39 AM, chucks <debashish@...> wrote:

I am trying to use the Bitronix Transaction Manager for a simple Oracle based
example (I am trying to run this example outside container). The connection
is not null, however, we get this exception when the statement is being
created. We are using Oracle Driver v11.2.0.1.0. The exception occurs
irrespective of whether AllowLocalTransactions is set to true or false.
Enough privileges have been granted already as instructed on
http://docs.codehaus.org/display/BTM/FAQ#FAQ-WhyisOraclethrowingaXAExceptionduringinitializationofmydatasource.

Following is the stack trace:
[2012-04-13 10:36:18,895] INFO  bitronix.tm.BitronixTransactionManager  -
Bitronix Transaction Manager version 2.1.2
[2012-04-13 10:36:18,907] WARN  bitronix.tm.Configuration  - cannot get this
JVM unique ID. Make sure it is configured and you only use ASCII characters.
Will use IP address instead (unsafe for production usage!).
[2012-04-13 10:36:18,921] INFO  bitronix.tm.Configuration  - JVM unique ID:
<xx.xx.xxx.xxx>
[2012-04-13 10:36:19,326] INFO  bitronix.tm.recovery.Recoverer  - recovery
committed 0 dangling transaction(s) and rolled back 0 aborted transaction(s)
on 0 resource(s) [] (restricted to serverId 'xx.xx.xxx.xxx')
[2012-04-13 10:36:22,053] INFO  bitronix.tm.recovery.IncrementalRecoverer  -
incremental recovery committed 0 dangling transaction(s) and rolled back 0
aborted transaction(s) on resource [oracle_dao_tests] (restricted to
serverId 'xx.xx.xxx.xxx')
java.sql.SQLException: error enlisting a JdbcConnectionHandle of a
JdbcPooledConnection from datasource oracle_dao_tests in state ACCESSIBLE
with usage count 1 wrapping
oracle.jdbc.xa.client.OracleXAConnection@679bfb30 on
oracle.jdbc.driver.OracleConnection@31884174
   at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.enlistResource(JdbcConnectionHandle.java:86)
   at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.prepareStatement(JdbcConnectionHandle.java:243)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at
bitronix.tm.resource.jdbc.BaseProxyHandlerClass.invoke(BaseProxyHandlerClass.java:63)
   at $Proxy0.prepareStatement(Unknown Source)
   at
itest.a.taxud.copis.dao.unit.BitronixTransactionTest.main(BitronixTransactionTest.java:44)
Caused by: bitronix.tm.internal.BitronixSystemException: cannot enlist an
XAResourceHolderState with uniqueName=oracle_dao_tests
XAResource=oracle.jdbc.xa.client.OracleXAResource@7d95d4fe with XID a
Bitronix XID [31342E39372E3131322E32303900000136AA18466500000000 :
31342E39372E3131322E32303900000136AA1850FA00000002], error=XAER_PROTO
   at
bitronix.tm.BitronixTransaction.enlistResource(BitronixTransaction.java:100)
   at
bitronix.tm.resource.common.TransactionContextHelper.enlistInCurrentTransaction(TransactionContextHelper.java:70)
   at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.enlistResource(JdbcConnectionHandle.java:84)
   ... 8 more
Caused by: javax.transaction.xa.XAException
   at
oracle.jdbc.xa.OracleXAResource.disallowLocalTxnMode(OracleXAResource.java:1047)
   at
oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:153)
   at
bitronix.tm.internal.XAResourceHolderState.start(XAResourceHolderState.java:219)
   at
bitronix.tm.internal.XAResourceManager.enlist(XAResourceManager.java:111)
   at
bitronix.tm.BitronixTransaction.enlistResource(BitronixTransaction.java:93)
   ... 10 more
[2012-04-13 10:36:22,976] INFO  bitronix.tm.BitronixTransactionManager  -
shutting down Bitronix Transaction Manager

Following is the code:

PoolingDataSource dataSource = new PoolingDataSource();
dataSource.setUniqueName("oracle_dao_tests");
dataSource.setClassName("oracle.jdbc.xa.client.OracleXADataSource");
dataSource.setMaxPoolSize(5);
dataSource.setAutomaticEnlistingEnabled(true);
dataSource.setAllowLocalTransactions(true);
dataSource.setTestQuery("SELECT 1 FROM DUAL");
dataSource.getDriverProperties().setProperty("user", "myUser");
dataSource.getDriverProperties().setProperty("password", "myPass");
dataSource.getDriverProperties().setProperty("URL",
"jdbc:oracle:thin:@localhost:1521:orcl");
dataSource.init();

BitronixTransactionManager btm =
TransactionManagerServices.getTransactionManager();
Connection connection = null;
PreparedStatement pstmt = null;

try {
   btm.begin();
   connection = dataSource.getConnection();
   if (connection != null) {
       pstmt = connection.prepareStatement(INSERT_QUERY);
   }

   if (pstmt != null) {
       pstmt.setString(1, "Test");
       pstmt.setInt(2, 1);
       pstmt.executeUpdate();
   }
   btm.rollback();
} catch (Exception ex) {
   ex.printStackTrace();
   try {
       btm.rollback();
   } catch (Exception e) {
       e.printStackTrace();
   }
} finally {
   dataSource.close();
   try {
       if (pstmt != null) pstmt.close();
       if (connection != null) connection.close();
   } catch (Exception e) {
       e.printStackTrace();
   }
   btm.shutdown();
}

Your help on this is appreciated.
--
View this message in context: http://old.nabble.com/OracleXAResource.disallowLocalTxnMode-exception-with-Bitronix-tp33679843p33679843.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



 « Return to Thread: OracleXAResource.disallowLocalTxnMode exception with Bitronix