[jboss-user] [JCA/JBoss] - XA Error Connecting to multiple Oracle XA Datasources

david.defrancesco do-not-reply at jboss.com
Mon May 14 18:40:20 EDT 2007


I am receiving the generic OracleXAException, XAException.XAER_RMERR, when trying to connect to multiple Oracle XA Datasources (Oracle version 10.2.0.2) within the same transaction. I have tried several different approaches to create the Oracle XA Datasources, including the thin driver, oci, oci8, and tns. I have followed the advice on the JBoss Wiki to add the following to the xa-datasource:

<track-connection-by-tx/>
<isSameRM-override-value>false</isSameRM-override-value>
<no-tx-separate-pools/>

I have tried enabling Pad for the org.jboss.tm.XidFactory and that doesn't seem to work.

I have verified with our Database Administrator that XA is enabled for Oracle 10.2.0.2, JAVA_XA packages are visible, and so is the DBA_PENDING_TRANSACTIONS view.

I have tried to run the code below using JBoss 4.2.0-GA and 4.2.0-CR2.

Anyone have any thoughts or run into this issue?

Thanks,
Dave

oracle-xa-ds.xml file content:


    <!-- Datasource 1 -->
    <xa-datasource>
        <jndi-name>ds1</jndi-name>
        <track-connection-by-tx/>
        <isSameRM-override-value>false</isSameRM-override-value>
        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
        <xa-datasource-property name="URL">jdbc:oracle:thin:@111.111.111.111:1521:ds1</xa-datasource-property>
        <xa-datasource-property name="User">xxx</xa-datasource-property>
        <xa-datasource-property name="Password">xxx</xa-datasource-property>

        <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
        <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
        <!-- Checks the Oracle error codes and messages for fatal errors -->
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

        <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
        <min-pool-size>0</min-pool-size>

        <!-- The maximum connections in a pool/sub-pool -->
        <max-pool-size>5</max-pool-size>

        <!-- The time before an unused connection is destroyed -->
        <!-- NOTE: This is the check period. It will be destroyed somewhere between 1x and 2x this timeout after last use -->
        <!-- TEMPORARY FIX! - Disable idle connection removal, HSQLDB has a problem with not reaping threads on closed connections -->
        <idle-timeout-minutes>0</idle-timeout-minutes>

        <!-- sql to call on an existing pooled connection when it is obtained from pool -->
        <check-valid-connection-sql>select * from dual</check-valid-connection-sql>

        <!-- example of how to specify a class that determines a connection is valid before it is handed out from the pool -->
        <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>

        <!-- Whether to check all statements are closed when the connection is returned to the pool,
             this is a debugging feature that should be turned off in production -->
        <track-statements/>

        <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
        <no-tx-separate-pools/>

        <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
        
            <type-mapping>Oracle9i</type-mapping>
        
    </xa-datasource>

    <!-- ACES Admin datasource -->
    <xa-datasource>
        <jndi-name>ds2</jndi-name>
        <track-connection-by-tx/>
        <isSameRM-override-value>false</isSameRM-override-value>
        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
        <xa-datasource-property name="URL">jdbc:oracle:thin:@111.111.111.111:1521:ds2</xa-datasource-property>
        <xa-datasource-property name="User">xxx</xa-datasource-property>
        <xa-datasource-property name="Password">xxx</xa-datasource-property>

        <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
        <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
        <!-- Checks the Oracle error codes and messages for fatal errors -->
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

        <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
        <min-pool-size>0</min-pool-size>

        <!-- The maximum connections in a pool/sub-pool -->
        <max-pool-size>5</max-pool-size>

        <!-- The time before an unused connection is destroyed -->
        <!-- NOTE: This is the check period. It will be destroyed somewhere between 1x and 2x this timeout after last use -->
        <!-- TEMPORARY FIX! - Disable idle connection removal, HSQLDB has a problem with not reaping threads on closed connections -->
        <idle-timeout-minutes>0</idle-timeout-minutes>

        <!-- sql to call on an existing pooled connection when it is obtained from pool -->
        <check-valid-connection-sql>select * from dual</check-valid-connection-sql>

        <!-- example of how to specify a class that determines a connection is valid before it is handed out from the pool -->
        <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>

        <!-- Whether to check all statements are closed when the connection is returned to the pool,
             this is a debugging feature that should be turned off in production -->
        <track-statements/>

        <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
        <no-tx-separate-pools/>

        <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
        
            <type-mapping>Oracle9i</type-mapping>
        
    </xa-datasource>

    
        <depends optional-attribute-name="TransactionManagerService">
            jboss:service=TransactionManager
        
    




Application code:

Inside a Servlet, JSP, or EJB, create a UserTransaction or let the container create the Transaction, and then get two connections, one from each database, and issue simple queries.

        UserTransaction utx = null;

        try {
            utx = (UserTransaction) getInitialContext().lookup("java:comp/UserTransaction");
            utx.begin();

            Connection conn1 = getConnection1();
            Connection conn2 = getConnection2();
            try {
                Statement s1 = conn1.createStatement();
                s1.execute("select count(*) from table");
                log.info("select count(*) from table");

                Statement s2 = conn2.createStatement();
                s2.execute("select count(*) from table");
                log.info("select count(*) from table");
            }
            catch (Exception e) {
                log.error("Exception", e);
            }
            finally {
                try {
                    conn1.close();
                    conn2.close();
                }
                catch (Exception e) {
                    //consume
                }
            }

            utx.commit();
        }
        catch (Exception e) {
            log.error(e);
        }

Stack Trace:
     [java] 18:14:13,541 ERROR [XAManagedConnectionFactory] Start transaction failed for org.jboss.resource.adapter.jdbc.xa.XAManagedConnection at a4f80e
     [java] 18:14:13,557 WARN  [TxConnectionManager] Connection error occured: org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventLi
stener at 5fa11b[state=NORMAL mc=org.jboss.resource.adapter.jdbc.xa.XAManagedConnection at a4f80e handles=0 lastUse=1179180853541 permit=true trackByTx=true mcp=
org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool at 1cd0037 context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@
1c94e11 xaResource=org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper at 4a0b66 txSync=null]
     [java] oracle.jdbc.xa.OracleXAException
     [java]     at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:938)
     [java]     at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:244)
     [java]     at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.start(XAManagedConnection.java:121)
     [java]     at org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper.start(JcaXAResourceWrapper.java:113)
     [java]     at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:775)
     [java]     at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:446)
     [java]     at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.enlist(TxConnectionManager
.java:773)
     [java]     at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:564)
     [java]     at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:337)
     [java]     at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:518)
     [java]     at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:399)
     [java]     at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
     [java]     at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)

     [java] 18:14:13,557 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.xastart] [com.arjuna.ats.internal.jta.transaction.arjunacor
e.xastart] TransactionImple.enlistResource - xa_start  - caught: XAException.XAER_RMERR for < 131075, 27, 25, 1--618d8c9a:9c1:4648d822:8b-618d8c9a:9c1:4648
d822:8e                                                                             >
     [java] 18:14:13,572 ERROR [STDERR] oracle.jdbc.xa.OracleXAException
     [java] 18:14:13,572 ERROR [STDERR]         at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:938)
     [java] 18:14:13,572 ERROR [STDERR]         at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:244)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.start(XAManagedConnection.java:121)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper.start(JcaXAResourceWrapper.java:113)
     [java] 18:14:13,588 ERROR [STDERR]         at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java
:775)
     [java] 18:14:13,588 ERROR [STDERR]         at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java
:446)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchroniz
ation.enlist(TxConnectionManager.java:773)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionMa
nager.java:564)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManage
r.java:337)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionMan
ager2.java:518)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.ja
va:399)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(Ba
seConnectionManager2.java:842)
     [java] 18:14:13,588 ERROR [STDERR]         at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)

     [java] 18:14:13,650 ERROR [UserAccountSessionEJB] org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; -
 nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac
, BasicAction: -618d8c9a:9c1:4648d822:8b status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enli
st in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource,
see the previous warnings. tx=TransactionImple < ac, BasicAction: -618d8c9a:9c1:4648d822:8b status: ActionStatus.ABORT_ONLY >))

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045611#4045611

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045611



More information about the jboss-user mailing list