wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Propagation of EJBException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Propagation of EJBException" Watch "Propagation of EJBException" New topic
Author

Propagation of EJBException

nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
How to deal with ejb excpetion and chagne it to application specific exception?

Thanks in advance
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
catch the exception,
throw a new exception, subclass of RuntimeException
(set the cause of the new exception to be the old exception)


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
As javax.ejb.EJBException is a subclass of RuntimeException, the EJB container will automatically rollback the transaction if you are using container-managed transactions.

You may decide that you do not want this to happen, so you just need to encapsulate EJBException in an instance of Exception or a subclass of it (but not RuntimeException) and throw that exception. The EJB container will not automatically rollback the transaction, so you will have to invoke setRollbackOnly() if you want a rollback.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
what about in case of RemoteException which is thrown by remote and well as local beans.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
What you say is not correct. The EJB container throws RemoteException
to a remote client or EJBException to a local client.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Propagation of EJBException