2 Replies Latest reply on Oct 28, 2001 10:06 AM by drcharris

    JDBC from inside MDB in 2.4.3 - transaction context propagat

    drcharris

      Anybody successfully got JDBC code running inside MDBs?

      I'm in the process of upgrading our project from JBoss 2.2.2 to 2.4.3 (Windows NT/2000) and I'm having problems with some of our MDBs. These all work fine in 2.2.2 but not in 2.4.3. We use JDK 1.3.0.

      These beans all follow a similar pattern - they receive update messages from other beans and use them to update tables in the database. We use the DefaultDS DataSource to get our JDBC connections, and get the DataSource through a resource-ref environment entry. The DataSource uses an XA-compatible driver and we use the org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl class as our DataSourceClass in jboss.jcml. The db is SQL Server 2000, we use version 4.13 of the inet Opta2000 driver.

      The problem is that in the MDB, despite the JDBC code successfully running (and executeUpdate() calls showing 1 affected row) the database does not get updated. I am assuming this is because the database transaction is not committing. My onMessage() method has a transaction attribute of Required, the MDB uses CMT so I would expect the connection to commit when onMessage() finishes.

      Anyone had the same problem? Anyone got JDBC working inside MDBs under 2.4.3? I'd be happy to post more info.

      c

        • 1. Re: JDBC from inside MDB in 2.4.3 - transaction context prop
          davidjencks

          If you really have an xa compatible driver you should be using its XADataSource class in the pool, not the fake xa jboss XADataSourceImpl. With the latter, even if it were to be working, there is a large chance you will actually be getting 2 independent transactions rather than one 2pc xa transaction.

          I don't know if this is the cause of your problem here, however. I think in 2.4.3 you can use log4j logging to log more events on the transaction commit path to find out if XAResource.prepate and commit are actually getting called.

          • 2. Re: JDBC from inside MDB in 2.4.3 - transaction context prop
            drcharris

            Thanks. I changed to use the drivers' own XA DataSource class but this just uncovered a whole bunch of other problems (because we'd never written code under a transactionally-aware setup)!

            I've now got all our database code sorted (i.e. I can get multiple beans to participate in a distributed transaction when they both do database work), the problem now is with coordinating transactions between database work and JMS publishing within a session bean. I'm getting 'invalid transaction id' messages when I publish the message.

            I shall persevere.