1Z0-895 · Question #72
Which is a correct way to define a runtime exception as an EJB 3.x application exception?
The correct answer is B. @ApplicationException. Use the @javax.ejb.ApplicationException annotation to specify that an exception class is an application exception thrown by a business method of the EJB. The EJB container reports the exception directly to the client in the event of the application error. java.lang.Object…
Question
Options
- Apublic class MyAppException extends javax.ejb.EJBException
- B@ApplicationException
- Cpublic class MyAppException extends javax.lang.EJBException
- D@ApplicationException
How the community answered
(17 responses)- A6% (1)
- B76% (13)
- C12% (2)
- D6% (1)
Explanation
Use the @javax.ejb.ApplicationException annotation to specify that an exception class is an application exception thrown by a business method of the EJB. The EJB container reports the exception directly to the client in the event of the application error. java.lang.Object java.lang.Throwable java.lang.Exception java.lang.RuntimeException javax.ejb.EJBException public class EJBException extends java.lang.RuntimeException The EJBException is thrown to report that the invoked business method or callback method could not be completed because of an unexpected error (e.g. the instance failed to open a database The following ProcessingException.java file shows how to use the @ApplicationException annotation to specify that an exception class is an application exception thrown by one of the business methods of the EJB: package examples; import javax.ejb.ApplicationException; /*** Application exception class thrown when there was a processing error* with a business method of the EJB. Annotated with the* @ApplicationException annotation.*/ @ApplicationException()public class ProcessingException extends Exception { Reference: Programming WebLogic Enterprise JavaBeans, Version 3.0 programming Application Exceptions
Topics
Community Discussion
No community discussion yet for this question.