Hi,
I have got the following question about
EJB 2.1 concerning Container- and Bean-managed transactions (CMT / BMT). We use WAS 6.1 for deployment and Oracle 10g as database, but I assume this does not matter...
-----------------------------------------------------------------------------------------------
Here is the scenario:
A MDB (Container-managed + transaction required specified) receives a message from a queue and then calls an operation of a Stateless EJB (bean-managed + requires new transaction specified). The MDB got the EJB through a JNDI lookup.
The Stateless EJB does this within the called operation:
myEJBSessionContext.getUserTransaction.begin();
doSomething...
myEJBSessionContext.getUserTransaction.commit();
return xyz;
The MDB receives the return value, does some more logic and finishes (then the MDB-transaction is committed through the container).
-----------------------------------------------------------------------------------------------
Is the above scenario legal regarding the EJB specifiation, or does the following rule apply (copied from a blog). Two possible explanations:
1) The scenario is illegal to use javax.transaction.UserTransaction in CMT ejb and the Container will throw java.lang.IllegalStateException if this is the case. javax.transaction.UserTransaction can be only used for BMT ejb (<transaction-type>Bean</transaction-type>).
OR:
2) The scenario is legal because a new EJB is created, and "requires new" suspends the transaction from the MDB while the Stateless EJB is used without Container-managed transactions. After finishing the Statelesss EJB and returning the value, the suspended MDB-transaction is re-activated.
Please help me and explain your answer. Thank you a lot...
Greetings Kai