• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 3063
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.
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic