• 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

EJBException and RemoteException

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference between EJBException and RemoteException ?
where and how are these exceptions catched by the EJB ?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic