EJB3 @TransactionTimeout at method level not working
pablo.fraga1975 Aug 7, 2009 2:33 PMHi,
I' am running JBoss 4.2.3-GA with EJB3 SLSB, transacction management is CMP (default), some operations, not all, needs more time of execution to work it out.
Between the 2 options of increasing the transaction timeout i choosed the one that applies at method level in each EJB, not the one at app. server level, 'cause i don't want to affect the whole container.
Code snapshot:
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@TransactionTimeout(15)
public AbstractResult compra(AbstractCommand command){
// sleep current thread for 10 seconds just to try transaction timeout
try {
Thread.currentThread().sleep(10000);
} catch (InterruptedException e1) {
log.error("Prueba de EJB3 transaction timeout");
}
// this goes the real code that interacts with RDBMS
...
}
The default transacction timeout to make the test was changed from 5 minutes (the default), to 5 seconds.
Server.log snap showing what it really happens:
18:29:42,781 INFO [CompraFacade] Start TX.
5 second later ... just after container transaction timeout ...
18:29:47,602 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id 7f000101:904f:4a79f497:75 invoked while multiple threads active within it.
18:29:47,602 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action 7f000101:904f:4a79f497:75 aborting with 1 threads active!
10 seconds later (just after sleep) the code that interacts with RDBMS is executed
18:29:52,788 INFO [CompraFacade] #### - INICIO Comienza Compra .......
18:29:53,138 FATAL [JEEConnectionProvider] Ocurrio un error al intentar establecer una conexión con la base de datos.
org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000101:904f:4a79f497:75 status: ActionStatus.ABORTED >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000101:904f:4a79f497:75 status: ActionStatus.ABORTED >)
From my point of view, what it really happens is that the @TransactionTimeout(15) is not working with CMP, but, if i change the transaction management to BMP it does work. I' m lost, does anyone have one explanation for this weird behavior?.
@TransactionManagement(TransactionManagementType.BEAN)
Any help would be very very appreciated.
Thanxs.