UserTransaction aUT = ctx.getUserTransaction();
Change the above to:
UserTransaction aUT = ctx.getUserTransaction(); aUT.setTransactionTimeout(360); aUT.begin();
i.e. set the transaction timeout before beginning the transaction.
Also, if you are expecting any exception to be thrown on a transaction timeout, then it wont happen. No exception is thrown, the transaction state will set to MARKED_FOR_ROLLBACK. Later on, if any operations are done using this transaction, only then will a exception be thrown.
You might want to verify whether the transaction timeout is working or not by checking the server logs, where you will see a WARN message from TransactionImpl saying that the transaction has timedout.
I wonder if
<mbean code="org.jboss.tm.TransactionManagerService" name="jboss:service=TransactionManager" xmbean-dd="resource:xmdesc/TransactionManagerService-xmbean.xml"> <attribute name="TransactionTimeout">3000</attribute>
in your conf/jboss-service.xml needs to be changed to