Page 1 of 1

About Question enthuware.oce-jpad.v6.2.407 :

Posted: Fri Jul 28, 2017 9:26 am
by himaiMinh
In the last explanation :
If the bean uses Container Managed Transactions, then the exception would be thrown because of sessionContext.getUserTransaction().
But if the bean is CMT, a user transaction can be created and suspends the current active container managed transaction according to table 13 of EJB specification.
Correct me if I am wrong.

Re: About Question enthuware.oce-jpad.v6.2.407 :

Posted: Fri Jul 28, 2017 9:59 am
by himaiMinh
I just found 13.6.2.10 from EJB spec :
If an instance of an enterprise bean with container-managed transaction demarcation attempts to invoke getUserTransaction method of the EJBContext, the container must throw the IllegalStateException
But in table 13, it says the CMT transaction will be suspended when the BMT transaction is started.

Are these two statements conflicting?

Re: About Question enthuware.oce-jpad.v6.2.407 :

Posted: Fri Jul 28, 2017 10:54 am
by himaiMinh
I think I can answer my own question about table 13.
What table 13 includes is a scenario like this:
1. A CMT bean A is running an active transaction.
2. This bean A calls BMT bean B, which has its own UserTransaction.
3. Bean B suspends bean A's active transaction until B's userTransaction completes.

What section 13.6.2.10 says is if bean A is a CMT, it cannot use EJBContext.getUserTransaction();otherwise, IllegalStateException will be thrown.

So, both statements are not conflicting.