[jboss-user] [EJB/JBoss] - EJB2.1:UserTransaction with CMT- possible bug?

mskonda do-not-reply at jboss.com
Mon May 21 07:30:52 EDT 2007


I have a CMT bean with a method set to Never as tx attribute. 

- If I get the UserTransction from SessionContext(), I do get an IllegalStateException (java.lang.IllegalStateException: CMT beans are not allowed to get a UserTransaction) which is expected
- However, I am able to get the same UT from JNDI!

I am successful in getting TransactionManager and UserTransaction from JNDI in my ejbCreate() method.

Now, the following method executes without any exceptions/restrictions/constraints:

  |     private void doNonTxWork()
  |     {
  |         logger.info("<< Method: doNonTxWork >>");
  |         try
  |         {
  |             Transaction t = tm.suspend();
  |             ut.begin();
  |             logger.info("UserTransaction BEGIN: ");
  |             ut.commit();
  |             logger.info("UserTransaction COMMITTED: ");
  |             tm.resume(t);
  |             logger.info("Transaction Resumed: ");
  |         }
  |         catch (Exception e)
  |         {
  |             logger.info("Exception:" + e.getMessage());
  |             logger.error(e);
  |             throw new EJBException(e);
  |         }
  |     }
  | 
Note that the method that's calling this one is set to Never. 

Now, in order to check whether I can do the same work in a Required method(which ideally should'nt work), I called this method from Required method. I didn't get any exceptions/errors and everything seems quite happy!!

Is it not strange behaviour(possible bug??) or am I missing something here?

Thanks
Madhu

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047192#4047192

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047192



More information about the jboss-user mailing list