Our architecture is like businessdelegate,sessionfacade,sessonbean and dao(J2EE desing pattern). I am facing problem in handling customized exception. I am throwing DAOException from dao to session,session facade & delegate. When it comes to session its throwing as daoexception only. when it comes to sessionfacade its throws as javax.trans.TransactionRolledBackException. I couldn't able to get the customized exception what i am throwing.
You may need to handle the exception again in the Session Bean. The Session Bean can throw various Exceptions. It can throw Rollback exception if the rollback transaction was caused by entity beans. The Best Approach is catch all exception in the SLSB. Convert it to USER Exception or re-throw them if they are User Exceptions. This will solve half of the problem. There might be still RemoteException for each of the Bean Method other than this customized User exception.
We also use the same set of VOA, DAO patterns. The best approach is not to do try and catch in these DAO, VOA package, declare them to be throwing EXception. Let the exception just be passed to the SLSB where you just handle all exception convert them according to the SLSB Business Method and throw meaningful Exceptions i.e. ItemNotFoundException, UpdateOrderFailedException.
But still the RemoteException is going to break the Presentation layer to handle all remote exception along with the User Exception. To solve this create a wrapper Command Pattern to handle all the SLSB calls for you. The generic exceute can execute any session bean method and will always return UserExceptions.
Thus you need is SLSB for the EJB Layer to convert all the SQLException and EJBException to user exception. Then use the Command Pattern to pass all the UserException and again Convert the RMI RemoteException to User Exception.
I hope you would understand this. This is kind of tricky. We did the same approach to save the JSP pages from displaying SQLException and other weird EJB Exceptions.