What will happen in a stateless or MDB with BMT demarcation if we throw an Application Exception after the transaction has been started but not commited ? According to specs, the app-exception will be re-thrown. But, according to specs too, these ejbs need to commit or rollback the transaction before the method ends.
javax.ejb.EJBException: Application error: BMT stateless bean MySLSFBean should complete transactions before returning (ejb1.1 spec, 11.6.1); nested exception is: bmtappexception.MyAppException Caused by: bmtappexception.MyAppException at bmtappexception.MySLSFBean.test(MySLSFBean.java:21)
So, even if you throw an application exception, you need to commit/rollback your transaction (probably in a finally clause).
Hope it helps,
SCJP5 | SCBCD5 | SCEA5 Part 1
posted 12 years ago
Thinking about it the two statements i've mentioned from the specs are really not contradictory. The exception will be rethrown and the method won't have commited or rollbacked, so a sytem-exception is thrown, the transaction rollbacked and the instance discarded .
Curse your sudden but inevitable betrayal! And this tiny ad too!