-
1. Re: EJB2.1:UserTransaction with CMT- possible bug?
waynebaylor May 21, 2007 10:11 AM (in response to mskonda)Why the call to tm.suspend()?
By marking the method with TransactionAttributeType.NEVER you're stating that there will not be a transaction in progress when the method is called.
Maybe try using TransactionAttributeType.NOT_SUPPORTED instead of NEVER. That way, if the caller has an associated transaction it will be suspended and restarted after the method executes. -
2. Re: EJB2.1:UserTransaction with CMT- possible bug?
mskonda May 21, 2007 10:24 AM (in response to mskonda)Thanks for your answer Wayne. Irrespective of the attrubute type, the use of UT is prohibited.
So my point is - the use of UT in CMT is not allowed according to EJB Spec but looks like we have a way to get around this restriction (if I am not missing something obvious :) )
Whenever my method obtains UT from SessionContext, it throw the expected IllegalStateException which is fine as expected.
BUT I am able to use JNDI to fetch UT and do the transactional work demarcating programmatically which isn't fine and not expected.
Regards
Madhu -
3. Re: EJB2.1:UserTransaction with CMT- possible bug?
waynebaylor May 21, 2007 4:33 PM (in response to mskonda)I just checked out the EJB3 Spec and found the following:
Section 13.6.5 Handling of Methods that Run with "an unspecified transaction context"
The term ?an unspecified transaction context? is used in the EJB specification to refer to the cases in
which the EJB architecture does not fully define the transaction semantics of an enterprise bean method
execution.
This includes the following cases:
? The execution of a method of an enterprise bean with container-managed transaction demarcation
for which the value of the transaction attribute is NOT_SUPPORTED, NEVER, or SUPPORTS.
? The execution of a PostConstruct, PreDestroy, PostActivate, or PrePassivate
callback method of a session bean with container-managed transaction demarcation.[71]
? The execution of a PostConstruct or PreDestroy callback method of a message-driven
bean with container-managed transaction demarcation.[72]
The EJB specification does not prescribe how the container should manage the execution of a method
with an unspecified transaction context?the transaction semantics are left to the container implementation.
My guess is that JBoss lets you use UserTransaction since there's no tx context defined. -
4. Re: EJB2.1:UserTransaction with CMT- possible bug?
mskonda May 22, 2007 3:35 AM (in response to mskonda)The execution of a method of an enterprise bean with container-managed transaction demarcation
for which the value of the transaction attribute is NOT_SUPPORTED, NEVER, or SUPPORTS.
However Wayne, I am able to use UT from a REQUIRED method too, which I think the above quote doesn't support.
Thanks
Madhu