[jboss-user] [EJB 3.0] - Transaction not rolling back in CONTAINER mode
umberto_soprano
do-not-reply at jboss.com
Fri Oct 5 07:54:59 EDT 2007
Hello,
I've a EHB3 Stateless bean who's using direct JDBC connections (no persistence manager) to store data in a database.
If I try to use TransactionManagement=CONTAINER Jboss seems to not execute roll backs in case of exceptions (both Application or Runtime exception). I inserted an as hoc thrown Exception to simulate the fault.
Managing TransactionManagement=BEAN works.
Any suggestion (code example below)?
CONTAINER mode (no rollback):
|
| @Stateless
| @javax.ejb.ApplicationException(rollback = true)
| @TransactionManagement(TransactionManagementType.CONTAINER)
| public class x implements y,z{
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Message processMessage() throws Exception
| {
|
| try {
| <<insert to DB>>
| << launch Exception>>
| } catch (Exception e1)
| {
| <<log>>
| throw e1;
| }}
|
|
BEAN mode (rollback executed):
|
| @Stateless
| @javax.ejb.ApplicationException(rollback = true)
| @TransactionManagement(TransactionManagementType.CONTAINER)
| public class x implements y,z{
|
| @Resource
| private UserTransaction utx;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Message processMessage() throws Exception
| {
|
| try {
| utx.begin();
| <<insert to DB>>
| << launch Exception>>
| utx.commit();
| } catch (Exception e1)
| {
| utx.rollback();
| <<log>>
| throw e1;
| }}
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091951#4091951
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091951
More information about the jboss-user
mailing list