2 Replies Latest reply on Mar 20, 2006 2:04 AM by Max Lam

    EJB3 Session Bean (Bean Managed Transaction) issue

    Max Lam Newbie

      Hi,

      I have a problem with getting bean managed transaction or more appropriately user managed transaction to work on my Session Bean (EJB3 specs.)

      I have a session bean with the EntityManager "em" already defined and I have a method xxx() which is suppose to rollback all which persistence when one of them failed.

      I tried to obtain the EntityTransaction by calling:

      EntityTransaction trxn = em.getTransaction();

      try
      {
      trxn.begin();
      //do something...
      trxn.commit();
      }
      catch(Exception ex)
      {
      trxn.rollback();
      }

      Unfortunately, JBoss throws IllegalStateException while calling em.getTransaction(). May I know how do I configure the session bean to be able to handle user managed transaction instead of container managed transaction (like the old days where we could define that in the ejb-jar.xml)? I'm running on JBoss 4.0.4RC1.

      Any help will be greatly appreciated. Thank you.