1 Reply Latest reply on Oct 5, 2012 3:01 PM by Justin Bertram

    Configuring JBoss AS7 for XA transations

    Daniel Spiess Newbie

      Hi,

       

      We're looking to configure JBoss AS7 to connect to mulitple databases.  This is what we have in our standalone.xml:

       

       

      <xa-datasource jta="true" jndi-name="java:/cdsPersistence" pool-name="cdsPersistence_pool" enabled="true" use-java-context="true" use-ccm="true">
                          <xa-datasource-property name="URL">
                              jdbc:oracle:thin:@our_db:1521:schema
                          </xa-datasource-property>
                          <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                          <driver>oracle</driver>
                          <xa-pool>
                              <min-pool-size>10</min-pool-size>
                              <max-pool-size>20</max-pool-size>
                              <prefill>true</prefill>
                              <use-strict-min>false</use-strict-min>
                              <flush-strategy>FailingConnectionOnly</flush-strategy>
                          </xa-pool>
                          <security>
                              <user-name>******</user-name>
                              <password>******</password>
                          </security>
                          <validation>
                              <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
                              <validate-on-match>false</validate-on-match>
                              <background-validation>false</background-validation>
                              <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
                              <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
                          </validation>
                          <timeout>
                              <set-tx-query-timeout>true</set-tx-query-timeout>
                              <blocking-timeout-millis>30000</blocking-timeout-millis>
                              <idle-timeout-minutes>30</idle-timeout-minutes>
                              <query-timeout>120</query-timeout>
                              <use-try-lock>60</use-try-lock>
                          </timeout>
                          <statement>
                              <prepared-statement-cache-size>32</prepared-statement-cache-size>
                          </statement>
                      </xa-datasource>
      
      

       

      We get these wanings non-stop in the logs:

       

       

      16:24:26,078 WARN  [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA016027: Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException
                at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:709)
                at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:358)
                at org.jboss.jca.core.tx.jbossts.XAResourceWrapperImpl.recover(XAResourceWrapperImpl.java:162)
                at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:503) [jbossjts-4.16.2.Final.jar:]
                at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:471) [jbossjts-4.16.2.Final.jar:]
                at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.bottomUpRecovery(XARecoveryModule.java:385) [jbossjts-4.16.2.Final.jar:]
                at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:166) [jbossjts-4.16.2.Final.jar:]
                at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [jbossjts-4.16.2.Final.jar:]
                at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [jbossjts-4.16.2.Final.jar:]
      
      

       

      From searching around it looks like we need to change the permissions in the database to correctly set up XA.

       

      These permissions give viewable access to the distributed transaction views, as well as the DBMS_SYSTEM package.  

       

      GRANT SELECT ON sys.dba_pending_transactions TO our_db;

      GRANT SELECT ON sys.pending_trans$ TO our_db;

      GRANT SELECT ON sys.dba_2pc_pending TO our_db;

      GRANT EXECUTE ON sys.dbms_system TO our_db;

       

      My questions/concerns are this..

       

      If JBoss is managing the distributed transactions, why does it need access to the views that are normally used by Oracle operations that call distributed transactions?

      Why the need to access the DBMS_SYSTEM package?

      What operations does XA try to execute using DBMS_SYSTEM?

      Is there another way/better way to configure distributed transactions?

       

      Thanks!

        • 1. Re: Configuring JBoss AS7 for XA transations
          Justin Bertram Master

          The WARN message you are seeing is not coming from an XA transaction, per se, but rather from the JBossTS transaction recovery manager as it attempts to query the datasource for any pending transactions.

           

           

          If JBoss is managing the distributed transactions, why does it need access to the views that are normally used by Oracle operations that call distributed transactions?

          JBossTS (the transaction manager used by JBoss AS7) doesn't care one iota about Oracle system tables.  It is simply invoking javax.transaction.XAResource.recover() (i.e. part of the JTA API) on a XA JDBC connection it got from the datasource.  For whatever reason, Oracle chose to implement this method call with internal calls that require these special permissions.

           

           

           

          Why the need to access the DBMS_SYSTEM package?

          I'm not an Oracle expert, but I recommend you direct this question at Oracle since their JTA implementation needs this.

           

          That said, in later versions of Oracle you don't have to grant execute on DBMS_SYSTEM.  You can grant execute on DBMS_XA instead.  Check with Oracle for more details on this.

           

           

          What operations does XA try to execute using DBMS_SYSTEM?

          Again, you'd need to ask Oracle that question.  As mentioned previously, the JBossTS transaction recovery manager is simply invoking javax.transaction.XAResource.recover().

           

           

          Is there another way/better way to configure distributed transactions?

          See above where you can grant execute on DBMS_XA instead of DBMS_SYSTEM.