Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Exception handling - regarding

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the choices marked as correct that i came across in ejbcertificate.com was
"..If the bean method throws an application exception but does not mark the transaction for rollback, the container will commit the transaction before re-throwing the application exception to the client..." - is the above statement correct ? Thought, HFEJB says that in case of application exceptions, the container would throw the exception as such to the client.
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure where you see the conflict there. Application exceptions do not cause an automatic rollbac. If the container started a transaction for the method, it will commit that transaction unless the bean code marked the transaction as rollback only before it threw the exception. In that case, the container will rollback the transaction. Either way, it will rethrow the exception back to the client.

If the container didn't start the transaction, but just used the one the client started, then it won't roll it back.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a bean's method is running in a transaction, then that transaction must complete before the method ends. As the throwing of the application exception causes the method to end, the container must end (commit) the transaction before the exception is rethrown to the client.

If a system exception were thrown by the bean, the container must end (rollback) the transaction before throwing RemoteException or EJBException to the client.
 
Sub swamy
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Greg and Roger.

Just to add on to this - for a BMT method we are expected to commit or rollback a transaction before the method ends. So, incase of a BMT method (MDB/stateless session bean) when we do not commit or rollback a transaction in code, can we assume that the container would commit the transaction when we assume that there is no exception being thrown.
 
Sub swamy
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it clarified - Page 356 of spec.
 
Your buns are mine! But you can have this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic