5 Replies Latest reply on Mar 14, 2006 7:54 AM by marklittle

    ArjunaTS and MySQL (Phorum)

    marklittle

      Author: Anton
      Date: 09-21-04 10:36

      I want to use Arjuna with a MySQL database (Version 4.0.20a).
      As a first step, I tried to make the sample banking application persistent. Therefore I changed the JNDI-Properties in com.arjuna.demo.jta.jdbcbank.BankClient and left com.arjuna.demo.jta.jdbcbank.Bank unchanged.

      I already tried different drivers, but I can't get a connection with any of them. With mm.mysql-2.0.13-bin.jar I get the following error:

      java.lang.ClassCastException: javax.naming.Reference
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource(IndirectRecoverableConnection.java:417)
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.(IndirectRecoverableConnection.java:116)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.(ConnectionImple.java:80)
      at com.arjuna.ats.internal.jdbc.ConnectionManager.create(ConnectionManager.java:90)
      at com.arjuna.ats.jdbc.TransactionalDriver.connect(TransactionalDriver.java:73)
      at com.arjuna.demo.jta.jdbcbank.Bank.create_table(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.Bank.(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)
      java.sql.SQLException: java.lang.ClassCastException: javax.naming.Reference
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource(IndirectRecoverableConnection.java:434)
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.(IndirectRecoverableConnection.java:116)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.(ConnectionImple.java:80)
      at com.arjuna.ats.internal.jdbc.ConnectionManager.create(ConnectionManager.java:90)
      at com.arjuna.ats.jdbc.TransactionalDriver.connect(TransactionalDriver.java:73)
      at com.arjuna.demo.jta.jdbcbank.Bank.create_table(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.Bank.(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)


      With xapool-1.4.jar (xapool.expertlog.com) it looks like this:
      java.sql.SQLException: Error trying to load driver: :
      at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:184)
      at org.enhydra.jdbc.standard.StandardPooledConnection.(StandardPooledConnection.java:65)
      at org.enhydra.jdbc.standard.StandardXAConnection.(StandardXAConnection.java:81)
      at org.enhydra.jdbc.standard.StandardXADataSource.getXAConnection(StandardXADataSource.java:109)
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createConnection(IndirectRecoverableConnection.java:448)
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.getConnection(IndirectRecoverableConnection.java:305)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.getConnection(ConnectionImple.java:557)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.registerDatabase(ConnectionImple.java:641)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.createStatement(ConnectionImple.java:141)
      at com.arjuna.demo.jta.jdbcbank.Bank.create_table(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.Bank.(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)
      java.sql.SQLException: java.sql.SQLException: Error trying to load driver: :
      at com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.getConnection(IndirectRecoverableConnection.java:327)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.getConnection(ConnectionImple.java:557)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.registerDatabase(ConnectionImple.java:641)
      at com.arjuna.ats.internal.jdbc.ConnectionImple.createStatement(ConnectionImple.java:141)
      at com.arjuna.demo.jta.jdbcbank.Bank.create_table(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.Bank.(Unknown Source)
      at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)

      I also tried gweMysql.jar (http://www.javareading.com/jdbc/) without success.

      Does anyone know, which driver works with MySQL and ArjunaTS? If it is not the driver, what else could I have made wrong?

      Thanks,
      Anton

        • 1. Re:  ArjunaTS and MySQL (Phorum)
          marklittle

          Author: julian.coleman
          Date: 09-21-04 15:43

          > I want to use Arjuna with a MySQL database (Version 4.0.20a).
          >
          > I already tried different drivers, but I can't get a
          > connection with any of them. With mm.mysql-2.0.13-bin.jar I get
          > the following error:
          >
          > java.lang.ClassCastException: javax.naming.Reference
          > at
          > com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource(IndirectRecoverableConnection.java:417)

          At this point, we're expecting an XADataSource instance, so it looks like the driver is not providing one, or the JNDI reference isn't correct.

          > With xapool-1.4.jar (xapool.expertlog.com) it looks like
          > this:
          > java.sql.SQLException: Error trying to load driver: :
          > at
          > org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:184)

          I'm not sure what causes this error, as it comes from the database drivers and not our code. I think it's from where we try to set the transaction isolation level. You could try changing the property:

          com.arjuna.ats.jdbc.isolationLevel

          to

          TRANSACTION_READ_COMMITTED

          and see if it works then.

          > Does anyone know, which driver works with MySQL and ArjunaTS?
          > If it is not the driver, what else could I have made wrong?

          As far as I can see, MySQL doesn't support two phase commit. This means that
          it won't be usable with ArjunaTS.

          J



          • 2. Re:  ArjunaTS and MySQL (Phorum)
            marklittle

            Author: Anton
            Date: 09-22-04 10:10

            Thank you for the fast reply.

            julian.coleman wrote:
            > > I want to use Arjuna with a MySQL database (Version
            > 4.0.20a).
            > >
            > > I already tried different drivers, but I can't get a
            > > connection with any of them. With mm.mysql-2.0.13-bin.jar I
            > get
            > > the following error:
            > >
            > > java.lang.ClassCastException: javax.naming.Reference
            > > at
            > >
            > com.arjuna.ats.internal.jdbc.IndirectRecoverableConnection.createDataSource(IndirectRecoverableConnection.java:417)
            >
            > At this point, we're expecting an XADataSource instance, so
            > it looks like the driver is not providing one, or the JNDI
            > reference isn't correct.

            The JNDI reference should be correct. Anyway, the author of the driver admits, that the "emulated XA transactions" do not work well. As a result this feature is removed in the newer version of the driver.

            > > With xapool-1.4.jar (xapool.expertlog.com) it looks like
            > > this:
            > > java.sql.SQLException: Error trying to load driver: :
            > > at
            > >
            > org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:184)
            >
            > I'm not sure what causes this error, as it comes from the
            > database drivers and not our code. I think it's from where we
            > try to set the transaction isolation level. You could try
            > changing the property:
            >
            > com.arjuna.ats.jdbc.isolationLevel
            >
            > to
            >
            > TRANSACTION_READ_COMMITTED
            >
            > and see if it works then.

            It also does not work with this property, throwing the same exception as before.

            > > Does anyone know, which driver works with MySQL and
            > ArjunaTS?
            > > If it is not the driver, what else could I have made
            > wrong?
            >
            > As far as I can see, MySQL doesn't support two phase commit.
            > This means that it won't be usable with ArjunaTS.

            Is it mandatory for the database to support two phase commit to be usable with ArjunaTS? Or is there a way to use a XA-aware JDBC Connection pool like XAPool. [which works in conjunction with JOTM (http://jotm.objectweb.org) and MySQL]


            In the meantime I tried to execute the example with Oracle (Version 9.2.0.1.0) and its native driver (ojdbc14.jar), but I also have an unsolved problems here.
            The BankClient is executing and also able to create the database, but if a UserTransaction starts (for example, creating an account), the resource cannot be enlisted:

            javax.transaction.SystemException: TransactionImple.enlistResource - XAResource.start [com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister] could not register transaction: oracle.jdbc.xa.OracleXid@e64686
            at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:607)
            at com.arjuna.ats.internal.jdbc.ConnectionImple.registerDatabase(ConnectionImple.java:680)
            at com.arjuna.ats.internal.jdbc.ConnectionImple.createStatement(ConnectionImple.java:141)
            at com.arjuna.demo.jta.jdbcbank.Bank.create_account(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.newAccount(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.start(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)
            java.sql.SQLException: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key ConnectionImple.registerDatabase -
            at com.arjuna.ats.internal.jdbc.ConnectionImple.registerDatabase(ConnectionImple.java:723)
            at com.arjuna.ats.internal.jdbc.ConnectionImple.createStatement(ConnectionImple.java:141)
            at com.arjuna.demo.jta.jdbcbank.Bank.create_account(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.newAccount(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.start(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)
            ERROR - javax.transaction.RollbackException
            javax.transaction.RollbackException
            at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1030)
            at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:112)
            at com.arjuna.demo.jta.jdbcbank.BankClient.newAccount(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.start(Unknown Source)
            at com.arjuna.demo.jta.jdbcbank.BankClient.main(Unknown Source)

            As the table is created, it seems that the DB access is ok, but transactions don't work. What's the reason for this error? Could I have forgotten any Oracle settings?

            Regards,
            Anton

            • 3. Re:  ArjunaTS and MySQL (Phorum)
              marklittle

              Author: Anton
              Date: 09-22-04 14:17

              The problem could be solved using a new jdbc driver (10.1.0) from the Oracle website.

              By the way: With the "old" driver I had a strange error, executing SQL-Statements without using transactions: Some Statements (f.e. CREATE) where executed correctly, while others (f.e. INSERT and UPDATE) made no changes in the database...

              > In the meantime I tried to execute the example with Oracle
              > (Version 9.2.0.1.0) and its native driver (ojdbc14.jar), but I
              > also have an unsolved problems here.
              > The BankClient is executing and also able to create the
              > database, but if a UserTransaction starts (for example,
              > creating an account), the resource cannot be enlisted:
              >
              > javax.transaction.SystemException:
              > TransactionImple.enlistResource - XAResource.start
              > [com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister]
              > could not register transaction:
              > oracle.jdbc.xa.OracleXid@e64686
              > at
              >com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:607)

              • 4. Re:  ArjunaTS and MySQL (Phorum)
                marklittle

                Author: Anton
                Date: 09-22-04 15:49

                > > As far as I can see, MySQL doesn't support two phase
                > commit.
                > > This means that it won't be usable with ArjunaTS.
                >
                > Is it mandatory for the database to support two phase commit
                > to be usable with ArjunaTS? Or is there a way to use a XA-aware
                > JDBC Connection pool like XAPool. [which works in conjunction
                > with JOTM (http://jotm.objectweb.org) and MySQL]

                There is a way to use MySQL with ArjunaTS. I only forgot to set the MySQL driver in XAPool's StandardXADataSource.
                If someone is interested in, this is a possibility to use the sample bank application with MySQL:

                import org.enhydra.jdbc.standard.StandardXADataSource;
                ...
                StandardXADataSource ds = new StandardXADataSource();
                ds.setDriverName("org.gjt.mm.mysql.Driver");
                ds.setUrl("jdbc:mysql://"+dbHost+":"+dbPort+"/"+dbName);

                The only thing you need is xapool.jar (http://xapool.experlog.com) in your CLASSPATH (and of course the mysql JDBC-driver)


                • 5. Re:  ArjunaTS and MySQL (Phorum)
                  marklittle

                  Author: julian.coleman
                  Date: 09-22-04 16:39

                  > Is it mandatory for the database to support two phase commit to be usable
                  > with ArjunaTS? Or is there a way to use a XA-aware JDBC Connection pool like
                  > XAPool. [which works in conjunction with JOTM (http://jotm.objectweb.org) and
                  > MySQL]

                  There isn't much point in using transactions if the database doesn't support
                  two phase commit, as without it, there is no way to co-ordinate the commit or rollback of multiple resources.

                  > The problem could be solved using a new jdbc driver (10.1.0) from the Oracle
                  > website.

                  We recommend using the Oracle JNDI drivers (classes12.jar for Oracle 9).

                  > By the way: With the "old" driver I had a strange error, executing SQL-Statements without using transactions: Some Statements (f.e. CREATE) where executed correctly, while others (f.e. INSERT and UPDATE) made no changes in the database...

                  Is this because the connection had auto-commit set to false?

                  > There is a way to use MySQL with ArjunaTS. I only forgot to
                  > set the MySQL driver in XAPool's StandardXADataSource.
                  > If someone is interested in, this is a possibility to use the
                  > sample bank application with MySQL:

                  As I mentioned above, if the database doesn't support two phase commit, there isn't much point in using it. For example, what will happen if one of your resources has to roll back? This could leave things in a inconsistent state
                  and the whole point of using transactions and two phase commit is to avoid that inconsistency happening.

                  J