2 Replies Latest reply on Oct 4, 2001 3:01 PM by Mike Squance

    Transaction rollback bug with entity bean business methods?

    Mike Squance Newbie

      Hi,

      I'm experiencing a problem when I have a business method of an entity bean marking a transaction for rollback. The rollback appears to occur correctly, but the next time I try to access a method of the same bean instance, the call blocks with the following message in the server:

      DEBUG 2001-10-01 12:58:48.606 [BeanA] LOCKING-WAITING (TRANSACTION) in Thread RMI TCP Connection(21)-207.81.211.121 for id one ctx.hash 1216346 tx:TransactionImpl:XidImpl [FormatId=257, GlobalId=HENRIK//7, BranchQual=]

      I originally experienced this because the business method was accessing another bean that was failing to load, which resulted in the transaction being marked for rollback. However, I can reproduce it with a business method as simple as:

      public int getSomeField()
      {
      entityContext_.setRollbackOnly();
      return 42;
      }

      The transaction attribute of all the methods of the bean are "Required".

      I'm using JBoss 2.4.0. With JBoss 2.2.1 I have a similar problem except that instead of hanging, it spins, repeating the message above over and over.

      Is this is a bug or is there something I'm missing?

      Thanks,
      Mike.

        • 2. Re: Transaction rollback bug with entity bean business metho
          Mike Squance Newbie

          Thanks for the suggestion, but I think I'm dealing with a different problem. It may be related, but at this point, I'm not ready to look at the JBoss source.

          I've reduced it down to a very simple case that doesn't even involve any actual transactions, connections, db access, etc.

          Here's what I've got:

          Home Interface:

          public interface DummyHome extends EJBHome
          {
          public Dummy create( int id ) throws RemoteException, CreateException;
          public Dummy findByPrimaryKey( Integer key ) throws RemoteException, FinderException;
          }

          Remote Interface:

          public interface Dummy extends EJBObject
          {
          public void someMethod() throws RemoteException;
          }

          EJB Implementation:

          public class DummyEEJB implements EntityBean
          {
          public Integer ejbCreate( int id ) throws CreateException
          { id_ = id; return new Integer( id_ ); }

          public void ejbPostCreate( int id ) { }

          public Integer ejbFindByPrimaryKey( Integer id ) throws FinderException
          { return id; }

          public void ejbRemove() { }

          public void ejbLoad() { }

          public void ejbStore() { }

          public void ejbActivate()
          {
          Integer id = (Integer) entityContext_.getPrimaryKey();
          id_ = id.intValue();
          }

          public void ejbPassivate() { }

          public void setEntityContext( EntityContext context )
          { entityContext_ = context; }

          public void unsetEntityContext() { }

          public void someMethod()
          { entityContext_.setRollbackOnly(); }

          private int id_ = 0;
          private EntityContext entityContext_ = null;

          }

          ejb_jar.xml:

          <ejb-jar>
          Test
          <display-name>Test</display-name>
          <enterprise-beans>

          <ejb-name>Dummy</ejb-name>
          com.asi.test.DummyHome
          com.asi.test.Dummy
          <ejb-class>com.asi.test.DummyEEJB</ejb-class>
          <persistence-type>Bean</persistence-type>
          <prim-key-class>java.lang.Integer</prim-key-class>
          False

          </enterprise-beans>

          <assembly-descriptor>
          <container-transaction>

          <ejb-name>Dummy</ejb-name>
          <method-name>*</method-name>

          <trans-attribute>Required</trans-attribute>
          </container-transaction>
          </assembly-descriptor>
          </ejb-jar>

          jboss.xml:


          <enterprise-beans>

          <ejb-name>Dummy</ejb-name>
          <jndi-name>test/Dummy</jndi-name>

          </enterprise-beans>



          If I have a client (non-EJB) that creates an instance, then calls someMethod() twice, the second call will hang with the LOCKING-WAITING message as above.

          I can work around this simple case by throwing an EJBException instead of calling setRollbackOnly and then its okay. However, my real scenario has another bean call involved which is failing (thus marking for rollback). In this case, if the context is marked for rollback, it doesn't seem to matter if I throw an EJBException. The result is the same.

          Any ideas or workaround suggestions would be appreciated.

          Thanks,
          Mike.