2 Replies Latest reply on Jun 8, 2009 8:55 AM by adrian.brock

    Problem with RA & inbound transaction -> MDB -> CMPs

    matterbury

      I have an EJB of 5 entity beans and 5 corresponding session beans. The only methods are to create an instance of an entity (it is a toy test case). All 5 entities must be created together due to FK constraints (each is created by invoking the 'create' method on the corresponding session bean). It works fine when invoked in a UserTransaction from a remtoe Java client program.

      I also have an RA and MDB that implement JCA inbound transactions. In response to requests, the RA creates an XID and creates an execution context in which the MDB is invoked, which invokes the EJBs methods.

      At the end, the RA tries to end (+ prepare + commit) the transaction, but this is failing because arjuna tries to update one of the created records but cannot find it, despite it logging earlier that it INSERTed it and that it found it using SELECT (I hand check each FK constraint in the SB's create method).

      AFAIK this means that the end is being executed in the wrong thread/context as otherwise it should find it (again).

      So, my questions are: is there any other reason the update could fail? how might I track down what's going wrong (I have turned on arjuna's DEBUG but it doesn't give enough detail for this)?

      FWIW, the actual exception is:

      2009-05-19 09:50:42,557 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.AddressEB] Executing SQL: UPDATE ADDRESS SET CITY=?, STATE=?, SUBURB_CODE=?, COUNTRY=?, TELEPHONE=?, EMAIL=?, cname=? WHERE LINE1=?
      2009-05-19 09:50:42,561 DEBUG [com.arjuna.ats.jta.logging.logger] BaseTransaction.getStatus
      2009-05-19 09:50:52,014 DEBUG [com.arjuna.ats.jta.logging.logger] TransactionImple.setRollbackOnly
      2009-05-19 09:50:52,014 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1971f66
      javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=875 Main St
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:169)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:666)
       at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:428)
       :
       :
       :
      


      TIA!

        • 1. Re: Problem with RA & inbound transaction -> MDB -> CMPs

           

          "matterbury" wrote:

          So, my questions are: is there any other reason the update could fail? how might I track down what's going wrong (I have turned on arjuna's DEBUG but it doesn't give enough detail for this)?

          FWIW, the actual exception is:
          2009-05-19 09:50:42,557 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.AddressEB] Executing SQL: UPDATE ADDRESS SET CITY=?, STATE=?, SUBURB_CODE=?, COUNTRY=?, TELEPHONE=?, EMAIL=?, cname=? WHERE LINE1=?
          2009-05-19 09:50:42,561 DEBUG [com.arjuna.ats.jta.logging.logger] BaseTransaction.getStatus
          2009-05-19 09:50:52,014 DEBUG [com.arjuna.ats.jta.logging.logger] TransactionImple.setRollbackOnly
          2009-05-19 09:50:52,014 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1971f66
          javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=875 Main St
           at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:169)
           at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:666)
           at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:428)
           :
           :
           :
          



          Ask the question in the EJB forum.

          If your quess is correct then the correct transaction is not associated
          with the thread when you do the prepare() and so the JDBCStoreManager()
          is trying to execute the storeEntity() during a transaction synchronization callback
          in the wrong transaction (or more probably no transaction)?

          • 2. Re: Problem with RA & inbound transaction -> MDB -> CMPs

            You should be able to test your guess by adding a BMP entity bean to your transaction
            and seeing what TransactionManager.getTransaction() is when ejbStore() is invoked
            at the end of the transaction.