• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Propagation of EJBException

 
nitin pokhriyal
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to deal with ejb excpetion and chagne it to application specific exception?

Thanks in advance
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
catch the exception,
throw a new exception, subclass of RuntimeException
(set the cause of the new exception to be the old exception)
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
nitin pokhriyal
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about in case of RemoteException which is thrown by remote and well as local beans.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you say is not correct. The EJB container throws RemoteException
to a remote client or EJBException to a local client.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic