aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Exception handling - regarding 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 "Exception handling - regarding" Watch "Exception handling - regarding" New topic
Author

Exception handling - regarding

Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
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.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

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.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
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

Joined: Oct 02, 2002
Posts: 121
Got it clarified - Page 356 of spec.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception handling - regarding