A session bean business method throws an exception during execution.
Which two are responsibilities of the Bean Provider when throwing the exception? (Choose two.)
A.
For application exceptions, ensure that ifthe current transaction commits there will be noloss ofdata integrity.
B.
For application exceptions, ensure that the current transaction will commit.
C.
For system errors, when the client is remote through a java.rmi.remoteException that wraps the original exception.
D.
For checked exceptions from which the bean cannot recover, throw an EJBException that wraps the original exception.
Explanation:
http://java.boot.by/scbcd5-guide/ch10s02.html
correct answer
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.
A system exception is defined as either a checked exception or an unchecked exception, from which an EJB method cannot recover.
When the EJB container intercepts an unchecked exception,
it rolls back the transaction and does any necessary cleanup. Then the container wraps the unchecked exception in a RemoteException and throws it to the client. Thus the EJB container presents all unchecked system exceptions to the client as RemoteExceptions (or as a subclass thereof, such as TransactionRolledbackException).
In the case of a checked exception,
the container does not automatically perform the housekeeping described above.
To use the EJB container’s internal housekeeping, you will have to have your checked exceptions thrown as unchecked exceptions. Whenever a checked system exception (such as a NamingException) occurs, you should throw javax.ejb.EJBException, or a subclass thereof, by wrapping the original exception. Because EJBException itself is an unchecked exception, there is no need to declare it in the throws clause of the method. The EJB container catches the EJBException or its subclass, wraps it in a RemoteException, and throws the RemoteException to the client.