Hello folks - working on my first J2EE project now.
I am trying to implement exception-handling with a facility to show detailed and informative error message to the user. We are using Struts. I am instantiating a simple Java bean (public class, implementing Serializable) from the ActionClass. I am passing this object on to the business delegate (stateless session) bean.
The delegate, in turn, passes this to a session facade (stateless session) bean.
The facade, in trun, passes this error bean to a DAO object, where lots of action takes place.
The idea is, at any point, when a exception is thrown, I will set a code into this error bean, and continue to normally propogate the exception using throw. I expect this to happen till I reach the ActionClass, where I will examine the bean, get the code, and fetch a nice message from a property file.
An error is simulated in DAO code; this causes the error object to be filled with a error code; this code is also visible to the Session facade bean (because objects are passed by reference). However, the business delegate is unable to get this code, in fact, if I preset the error object with some junk code in the business delegate before passing the object to the facade, it continues to hold this value even after returning from the facade!
Does this mean, between two session beans, we do not have reference passing of objects? Between session beans, is the mechanism always pass-by-value even for entire objects?
Else, what could be wrong? Please suggest. Thanks for reading this longish post, and thanks for any help.
Also pls suggest how this approach can be further improved.
Regards/Harish
[ March 17, 2006: Message edited by: Harish Vaishnav ]