Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application exceptions and BMT

 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic