Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Application exceptions and BMT

 
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.

 
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 .
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic