I have an EJB method called methodA() calling another EJB method called methodB() which starts a new container managed transaction. in methodB, I am forcing a transaction timeout which is rightly caught by caughtB and not propagated to methodA. But I am surprised that methodA receives the Exception. Am I missing soemthing here?
methodA() {
try {
methodB();
System.out.println("print me!");
} catch(Exception e) {
System.out.println("shouldn't be here");
}
}
@TransactionTimeout(5) //5 sec timeout
methodB() {
try {
Thread.sleep(6000);
} catch(Throwable t) {
System.out.println("Eating all the Exception..");
}
}
The first method should have never caught the exception (EJBTransactionTimeoutException) because the methodB have eaten it. I am seeing the output of "Shouldn't be here" instead of "print me!". It makes me wonder if container throws yet another exception of EJBTransactionTimeoutException immediately after methodB is completed although it has already thrown Timeout exception?