aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Application exceptions and BMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Application exceptions and BMT" Watch "Application exceptions and BMT" New topic
Author

Application exceptions and BMT

Pedro Erencia
Ranch Hand

Joined: Apr 03, 2008
Posts: 70
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.

Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
Hi Pedro,

I did a little test with my JBoss:



And the result is:
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,

Beno�t


SCJP5 | SCBCD5 | SCEA5 Part 1
Pedro Erencia
Ranch Hand

Joined: Apr 03, 2008
Posts: 70
Thanks Beno�t.

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 .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Application exceptions and BMT