Hi,
I am abit puzzle at this and any insight will be appriciated. I have a session bean where in a method signiture it thows a custom exception call "UserNotFoundException". The exception is exposed to the remote interface.
In my web teir I have use reflection to discover this bean and ionvokes its appropriate method.
All well and good but why is it when I through the "UserNotFoundException" in my session bean I get a stack trace in my log even though it is being caught by "InvocationTargetException" in my reflection proceedures??
I am using the ejb's remote interface if thats a reason for it...
Thanks for any insight..
Charlie
-
Exceptions between ejb and web (4 messages)
- Posted by: Charles Lee
- Posted on: June 21 2005 09:04 EDT
Threaded Messages (4)
- Because u are using reflection by Sowmya Sridhar on June 21 2005 10:22 EDT
- Getting the cause is not the problem by Charles Lee on June 21 2005 10:51 EDT
- Exceptions between ejb and web by sawan parihar on June 27 2005 00:22 EDT
- Exceptions between ejb and web by sawan parihar on June 27 2005 05:04 EDT
-
Because u are using reflection[ Go to top ]
- Posted by: Sowmya Sridhar
- Posted on: June 21 2005 10:22 EDT
- in response to Charles Lee
Because u are using reflection - u are getting the InvokationTargetException. It will have the user exception wrapped internally. The getCause() and the getTargetException() methods can be used to get the real exception the session bean has thrown. -
Getting the cause is not the problem[ Go to top ]
- Posted by: Charles Lee
- Posted on: June 21 2005 10:51 EDT
- in response to Sowmya Sridhar
Maybe I miss understood your answer. I can get the cause from the exception thrown by InvokationTargetException.
What I don't understand is that why my session ejb is still printing a stack trace even tho the exception was caught.
For example (in te POJO world). I have 2 classes A and B. Class B is written like this:
public class B{
public void someMeth throws Exception(){
throw new Excpetion();
}
}
If class A calls B.someMeth() and surronds the B.someMeth() with a try/catch loop no stack trace will be printed (unless I code it to print the exception)
Now in my question is that Class B is the session bean and when my servlet (i.e. class A) calls my session bean (using reflection the ejb contanier prints the exception even tho it is caught by InvokationTargetException. -
Exceptions between ejb and web[ Go to top ]
- Posted by: sawan parihar
- Posted on: June 27 2005 00:22 EDT
- in response to Charles Lee
Hi,
Well the application exceptions won't be logged. Its only the system exceptions that get logged. Can you try wrapping your exception in EJBException and then throwing it. I think that its because of the RemoteException (which is a checked exception but is considered as system exception) that its getting logged.
Cheers.
Sawan -
Exceptions between ejb and web[ Go to top ]
- Posted by: sawan parihar
- Posted on: June 27 2005 05:04 EDT
- in response to sawan parihar
Just a correction in my previous post .
"Can you try wrapping your exception in EJBException and then throwing it".This will get logged
sawan