• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Understanding Exception

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In FHEJB p543, it said

If your business logic catches an exception which the client is not expecting, wrap it and rethrow it as an EJBException.


My question is that it depends on the client is remote or local, if it is local client, yes, rethrow it as an EJBException. But if it is a remote client, I think it should be wrapped and rethrown as an RemoteException.
Correct me if I am wrong
[ April 18, 2004: Message edited by: Alibabra Sanjie ]
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alibabra,
Your bean methods should never throw a RemoteException, even though they may declare that RemoteExceptions can be thrown. It's the container's job to throw RemoteExceptions. If you throw an EJBException (like you should), the container will wrap it into a RemoteException for you if the client is remote.
To illustrate this, consider the fact that you have no way of knowing whether the client is remote or local (unless of course you only expose one of those component interfaces and can make the assuption).
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your bean class should never declare or throw RemoteExceptions. Remember bean class is not a remote object. It can only throw application exceptions or runtime exceptions (EJBException).
 
reply
    Bookmark Topic Watch Topic
  • New Topic