Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Understanding Exception

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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).
 
What? What, what, what? What what tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic