• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Understanding Exception

 
Alibabra Sanjie
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 ]
 
Nathaniel Stoddard
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).
 
Sany Bel
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic