Harish Vaishnav

Greenhorn
+ Follow
since Mar 17, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Harish Vaishnav

jaikiran pai:

My situation is like this: there is a need to present detailed message to the user. We have decided that instead of defining custom exceptions extending java.lang.Exception, we will create a small class instead:

public class CustomError {
int eCode;
String eMsg;
String userAction;
...
...
}

We will pass this class's object along all the way from ActionClass to the DAO layer where, potentially, this object will be filled with a error code. (If this object were to be filled, we will also have come out of any trans due to "throw new EJBException();")

So, we are not subclassing Exception at all in this approach, relying entirely on java's default "pass-by-reference" behavior for objects to retrieve it back in the ActionClass for further action.

This expected java "pass-by-reference" behavior is failing at the business delegate, and I cannot get back the same object I set into circulation from the ActionClass. Instead, I am stuck with the object originally sent into the delegate from the ActionClass.

Hope you understand my problem.
jaikiran pai:

Thanks for the response.

- How would the application exception contain the error code?

- Since I am using a custom error object, which contains the error code, I can afford to only fill up this object and then always throw new EJBException(e), which I believe causes the container to rollback.

So, by using a simple error object, I plan to give a better user response without losing container tran management. But I am facing the problem I described earlier.
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 ]