I have bean using BMT. Another bean using BMT is injected into the first. Now when the first one calls a method of the second one, suddenly the transaction is closed. In my code I narrowed it down to exactly the point before the method call and inside of it.
Here is the trace:
2018-11-23 12:15:32,275 +0100 [TRACE] [com.arjuna.ats.jta] (default task-18) TransactionImple.getStatus: javax.transaction.Status.STATUS_ACTIVE
2018-11-23 12:15:32,276 +0100 [TRACE] [com.arjuna.ats.jta] (default task-18) TransactionImpleManager.suspend
2018-11-23 12:15:32,277 +0100 [TRACE] [com.arjuna.ats.jta] (default task-18) TransactionSynchronizationRegistryImple.getTransactionKey
example code:
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class A{
@Inject
private B b;
@Inject
private UserTransaction trx;
public void foo(){
trx.begin();
//transaction is active
b.bar();
trx.commit();
}
}
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class B{
public void bar(){
//transaction is closed
//whatever
}
}
Happens on JBoss EAP 7.0.9.
I have this constellation in lots of places, but only here it breaks. Am I missing something basic? Where can I look for additional clues?
Short answer: BMTs don't get propagated to other beans using BMTs. It's simply not possible to have a transaction spanning code in both beans.
(Except if you hack the JBoss TransactionManager to always get the same DB transaction.)