Wednesday, March 16, 2011

Transaction Timeout in JBoss

as explained here (it doesn't go in too much detail though...)

in conf/jboss-service.xml you will find either:

mbean code=""
attribute name="TransactionTimeout" 300

mbean code="com.arjuna.ats.jbossatx.jta.TransactionManagerService"
attribute name="TransactionTimeout" 300

(JBoss can be configured with either TM)

otherwise you can annotate your EJB method with

(value is in SECONDS I suppose)

but apparently this annotation works only with the jboss TM

Here the also complain about this.

Anyway you can still grab the transaction and set timeout in your code...ONLY IF YOU DO BMT!

don't use EntityManager.getTransaction(), this is a EntityTransaction and will not expose you the UserTransaction timeout...

you have the SessionContext (=EJBContext) injected this way:

private SessionContext sctx;


if you do this on a CMT, you get this:

java.lang.IllegalStateException: Container bla: it is illegal to inject UserTransaction into a CMT bean
at org.jboss.ejb3.BaseSessionContext.getUserTransaction(


No comments: