|
INTERVIEW QUESTIONS
J2EE
EJB
DETAILS
Question: Is there a way to get the original exception object from inside a nested or wrapped Exception (for example an EJBException or RemoteException)
Answer: Yes. The way to get, depends on the Exception, since there are no standards. Some examples:
* When we have an javax.ejb.EJBException, we can use the getCausedByException() that returns a java.lang.Exception.
* A java.rmi.RemoteException there is a public field called detail of type java.lang.Throwable
* With a java.sql.SQLException we need to use the method getNextException() to get the chained java.sql.SQLException.
* When we have an java.lang.reflect.InvocationtargetException, we can get the thrown target java.lang.Throwable using the getTargetException() method.
Submitted by Parthasarathy K ([email protected])
________________
Absolutely yes, but the way to do that depends on the Exception, since there are no standards for that. Some examples:
* When you have an javax.ejb.EJBException, you can use the getCausedByException() that returns a java.lang.Exception. * A java.rmi.RemoteException there is a public field called detail of type java.lang.Throwable * With a java.sql.SQLException you need to use the method getNextException() to get the chained java.sql.SQLException. * When you have an java.lang.reflect.InvocationtargetException, you can get the thrown target java.lang.Throwable using the getTargetException() method.
As usual, the best way to check how to get that piece of information is to read the documentation of the specific Exception.
Submitted by Vijay Kumar ([email protected])
|
|
|
Category |
EJB Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 8117 users |
Added on |
10/14/2010 |
Views |
78074 |
Rate it! |
|
|
Question:
Is there a way to get the original exception object from inside a nested or wrapped Exception (for example an EJBException or RemoteException)
Answer:
Yes. The way to get, depends on the Exception, since there are no standards. Some examples:
* When we have an javax.ejb.EJBException, we can use the getCausedByException() that returns a java.lang.Exception.
* A java.rmi.RemoteException there is a public field called detail of type java.lang.Throwable
* With a java.sql.SQLException we need to use the method getNextException() to get the chained java.sql.SQLException.
* When we have an java.lang.reflect.InvocationtargetException, we can get the thrown target java.lang.Throwable using the getTargetException() method.
Submitted by Parthasarathy K ([email protected])
________________
Absolutely yes, but the way to do that depends on the Exception, since there are no standards for that. Some examples:
* When you have an javax.ejb.EJBException, you can use the getCausedByException() that returns a java.lang.Exception. * A java.rmi.RemoteException there is a public field called detail of type java.lang.Throwable * With a java.sql.SQLException you need to use the method getNextException() to get the chained java.sql.SQLException. * When you have an java.lang.reflect.InvocationtargetException, you can get the thrown target java.lang.Throwable using the getTargetException() method.
As usual, the best way to check how to get that piece of information is to read the documentation of the specific Exception.
Submitted by Vijay Kumar ([email protected]) Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All EJB Interview Questions & Answers - Exam Mode /
Learning Mode
|