When a (transactional) method of an EJB calls another (transactional) method of another EJB, and an exception is thrown in the second, but catched in the first one, it seems that the transaction is automatically rolled back when the second one returns, even if the first one catches it, is this true? how can I avoid it?
The scenario is the following one:
@Stateless
class ClassA {
@EJB
ClassB objectB;
methodA() {
try {
objectB.methodB();
}
catch(Exception e) {
//Here the transaction started in this method is
//automatically rolled back. Is this avoidable?
}
}
}
@Stateless
class ClassB {
methodB() throws Exception { throw new Exception() }
}