A session bean business method throws an exception during execution.
Which two are responsibilities of the Bean Provider when throwing the exception? (Choose two.)
Correct Answer: A,D
Explanation/Reference:
D: If the bean method performs an operation that results in a checked (i.e. not a subclass of java.lang.RuntimeException) exception that the bean method cannot recover, the bean method should throw the javax.ejb.EJBException that wraps the original exception.
A: The Bean Provider MUST do one of the following to ensure data integrity before throwing an application exception from an enterprise bean instance:
* Ensure that the instance is in a state such that a client's attempt to continue and/or commit the transaction does not result in loss of data integrity. For example, the instance throws an application exception indicating that the value of an input parameter was invalid before the instance performed any database updates.
* If the application exception is not specified to cause transaction rollback, mark the transaction for rollback using the EJBContext.setRollbackOnly method before throwing the application exception. Marking the transaction for rollback will ensure that the transaction can never commit.
Reference: Identify correct and incorrect statements or examples about application exceptions and system exceptions in session beans and message-driven beans, and defining a runtime exception as an application exception.
http://java.boot.by/scbcd5-guide/ch10s02.html