Hi Guys, I did a summary after reading exception of HFEJB --- all the RuntimeException (such as nullpointerexception, indexoutofarrayexception...) plus RemoteException thrown by bean, the remote client will only get RemoteException while the local client will only get EJBException. As for those exceptions thrown by container or stub, need do more detail analysis.
Is my summary right? It it is, then it will help us to remember those various exceptions Any suggestion is welcomed.
Originally posted by Roger Chung-Wee: RemoteException must never be thrown by a bean.
Thanks Roger, that's correct, I have overlooked that one in Hai's post.
A RemoteException can only be thrown by the container when: 1. the bean throws a system exception (a RuntimeException or a checked exception wrapped in an EJBException) AND 2. there is no caller transaction available
See my cheatsheet for more details...
My Linked In
posted 16 years ago
For session and entity beans, RemoteException is thrown regardless of the caller transaction.
If a business method of a CMT session bean or a CMT entity bean throws a non-application exception, the container will then always throw RemoteException to a remote client.
If the method was running with an unspecified transaction context or in the context of a transaction which the container had started immediately prior to running the method, RemoteException will be thrown.
If the bean method was running in the context of the caller�s transaction, javax.transaction.TransactionRolledbackException will be thrown. As this exception IS-A RemoteException, I am able to say that RemoteException is always thrown.
Right Roger, that summarizes well (and in plain english) the lower part of my cheatsheet
The only point I forgot to clarify in my previous post (and you did it well, thank you for that ) is that TransactionRolledbackException extends from RemoteException and thus my statement should have been:
A RemoteException (or subclass thereof) is always thrown by the container when the bean throws a system exception (a RuntimeException or a checked exception wrapped in an EJBException) to remote clients.
Thanks for the clarification
My Linked In
There's a way to do it better - find it. -Edison. A better tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop