This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJBException and RemoteException  RSS feed

 
Raj Jindal
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between EJBException and RemoteException ?
where and how are these exceptions catched by the EJB ?
 
Viswanatha GB
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You should never explicitly throw a RemoteException as of EJB1.1 or later. Instead you should either throw an EJBException (or subclass thereof) in the case of a system exception or a subclass of Exception in the case of an application exception. The EJB Spec talks about this in detail in the "Exception Handling" section
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As of EJB2.0, any System Exception/Unchecked exception caught by the EJB Container, while executing the method of the bean, is thrown as a RemoteException if the client is a remote client and EJBException if the client is a local client.
As Viswanath said, the bean provider while coding the bean class, is responsible to catch the checked exception if any, wrap it in an EJBException and throw it as an EJBException. The container will catch this EJBException and rethrow it either as RemoteException or EJBException
based on the client, if it is remote or local.
RemoteException is a checked exception while EJBException is an unchecked exception.
For more information about EJB Exception Handling, U can refer Ed Roman's book, Appendix E - Exception Reference, p:648
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishwa,

What you're saying is that we should only return EJBExceptions from business methods (as in the case for SLSB). But as far as I understand, that will ALWAYS cause a rollback to happen. And it's not always the case that we need rollbacks e.g. checking parameters to be non-null. So your advice is not entirely correct.

Regards,

Pho
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!