6 Replies Latest reply on Feb 24, 2009 6:23 AM by Mauro Molinari

    Passing flags into xaResource.start(..) for Oracle Loose Cou

    Mark Johnson Newbie

      After much debugging, I can across a problem with using the Oracle XA driver (v 11.1) in JbossAS 5.0 with JbossTS (both JTA and JTS configurations)

      Our environment is a single Oracle 9i instance with multiple users. Each one of these users is configured using an XA datasource.

      Something changed in the Transaction manager between JBossAS 4.2 and 5.0 where the transaction is started differently. When sharing an XA transaction across users in the same instance, the transaction has to be started with the xa_open parameter Loose_Coupling=true. The oracle JDBC driver has a way to do this by passing the flag: OracleXAResource.ORATRANSLOOSE into the xaresource.start method.

      If the flag is not passed, Oracle will fail with an exception when a query is run on the second user in the transaction.

      (wow, my week's worth of research can be summed into 2 paragraphs, thats depressing)

      I found a way to pass the flag by wrapping the Oracle XADataSource, XAResource, and PooledConnection classes with simple pass through implementations to the Oracle driver. In the start method of my wrapped XAResource class, I OR the oracle parameter to the flags passed in by JBossTS.

      @Override
       public void start(Xid xid, int flags) throws XAException {
       res.start(xid, flags | OracleXAResource.ORATRANSLOOSE);
       }
      


      I then use my wrapped XADataSource in the -ds.xml configuration file instead of the Oracle one.

      So, my question is, is there a way that I can pass this flag without wrapping the classes? Perhaps via an interceptor somewhere (I am still trying to wrap my head around the multitude of JBoss Interceptor options)

      If anyone is interested in duplicating this behavior, i'd be happy to post the instructions on how to do so, it isn't terribly difficult.


        • 1. Re: Passing flags into xaResource.start(..) for Oracle Loose
          Mark Little Master

          What makes you think something has changed around TS to prevent what you're doing working?

          • 2. Re: Passing flags into xaResource.start(..) for Oracle Loose
            Mark Johnson Newbie

            I used the same oracle drivers, exact same ear, and the same data source configuration file between JBoss 4.2.0.GA and 5.0.0.GA

            The error only manifests itself in JBoss 5.0.0

            Jboss 4 startup:

            09:44:09,613 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
            ...
            09:44:27,441 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle9i Release 9.2.0.4.0 - Production
            JServer Release 9.2.0.4.0 - Production
            09:44:27,441 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 11.1.0.7.0-Production
            


            and Jboss 5 startup:
            09:49:33,722 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
            ...
            09:49:39,410 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle9i Release 9.2.0.4.0 - Production
            JServer Release 9.2.0.4.0 - Production
            09:49:39,410 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 11.1.0.7.0-Production
            



            Both of these are running under JDK 1.6_11 on a win XP machine.

            The JBoss 4.2.0 instance has no problems connecting to both data sources, but the 5.0. version throws cryptic exceptions when the second datasource is queried against in the same transaction.

            I am using the 'standard' config in JBoss 5, and the default config in JBoss 4.2.


            But let me throw one more confusing wrench in there. If I use an Older Oracle driver version, 10.2.0.1.0, the JBoss 4.2 works fine, but 5.0 does not work, either via my wrapped implementation or standard.

            Thanks for your help!


            • 3. Re: Passing flags into xaResource.start(..) for Oracle Loose
              Mark Little Master

              Hmmm, not exactly sure what might have changed in the ts code to affect that. I'll check with the team.

              • 4. Re: Passing flags into xaResource.start(..) for Oracle Loose
                Mark Johnson Newbie

                I guess the underlying point is still, Can I pass additional flags to the Transaction Manager when a transaction was started?

                • 5. Re: Passing flags into xaResource.start(..) for Oracle Loose
                  Jonathan Halliday Master

                  > Can I pass additional flags to the Transaction Manager when a transaction was started?

                  In JBossTS stanalone it is possible using modifier classes and an extended version of enlistResource(), but the app server does not and never has used that feature.

                  This is most likely down to a JCA behaviour change, perhaps related to the way transaction branches work. Try the JCA forum or send me a test case and I'll take a look when I have time.

                  • 6. Re: Passing flags into xaResource.start(..) for Oracle Loose
                    Mauro Molinari Novice

                     

                    "JavaJohnson" wrote:
                    After much debugging, I can across a problem with using the Oracle XA driver (v 11.1) in JbossAS 5.0 with JbossTS (both JTA and JTS configurations)

                    Our environment is a single Oracle 9i instance with multiple users. Each one of these users is configured using an XA datasource.

                    Something changed in the Transaction manager between JBossAS 4.2 and 5.0 where the transaction is started differently. When sharing an XA transaction across users in the same instance, the transaction has to be started with the xa_open parameter Loose_Coupling=true. The oracle JDBC driver has a way to do this by passing the flag: OracleXAResource.ORATRANSLOOSE into the xaresource.start method.

                    If the flag is not passed, Oracle will fail with an exception when a query is run on the second user in the transaction.


                    Hi JavaJohnson!
                    Is the exception you were receiving related to an XMER_NOTA XAException?

                    I am facing problems with a similar situation but I couldn't succeed to solve it even adding the flag OracleXAResource.ORATRANSLOOSE you mention :-( By the way, I also came to the conclusion of wrapping all those classes...

                    By the way, I found that another way of setting that flag without wrapping all those classes is to set a connection property in the OracleXADataSource:

                     // ds is my OracleXADataSource
                     ds.getConnectionProperties().setProperty(OracleDriver.xa_trans_loose, Boolean.TRUE.toString();
                    


                    However, by debugging I can't really understand whether the OracleXAResource is really setting the flag or not. You may try and see if it works for you.

                    By the way, I opened the following thread:
                    http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151003

                    Mauro.