On p.58 of Frits's notes, there are two guidelines about handling system exceptions:
"1. If the
EJB method performs an operation that results in a checked exception that the bean method cannot recover, the bean method should throw the EJBException that wraps the original exception."
My comment : can we throw RemoteException that wraps the original exception instead?
"2. Any other unexpected error conditions should be reported using the EJBException."
My comment : can we throw RemoteException instead ?
I am reading Head First EJB 2.0 for fun now. On p. 539 of the book, it says a rule "RemoteException goes to remote clients , EJBException goes to local client".
It says "RemoteException is for remote client only.... EJBException is for local clients only."
Is the rule applied to EJB 3.0? In EJB 3.0, is there any clear guideline when the bean should throw RemoteException and when the bean should throw EJBException.
For example, if the bean fail to obtain a database connection or fail to look up in JNDI, which exception the bean should throw ? RemoteException or EJBException ? Or it doesn't matter.