Which is a correct way to define a runtime exception as an EJB 3.x application exception?
A.
public class MyAppException extends javax.ejb.EJBException
B.
@ApplicationException
public class MyAppException extends javax.ejb.EJBException
C.
public class MyAppException extends javax.lang.EJBException
D.
@ApplicationException
public class MyAppException extends javax.lang.EJBException
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.
Note:
java.lang.Object
java.lang.Throwable
java.lang.Exceptionjava.lang.RuntimeException
javax.ejb.EJBException
javax.ejb
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
connection).
Example:
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