nerdexam
Oracle

1Z0-898 · Question #7

A session bean business method throws an exception during execution. Which two are responsibilities of the Bean Provider when throwing the exception? (Choose two.)

The correct answer is A. For application exceptions, ensure that if the current transaction commits there will be no loss D. For checked exceptions from which the bean cannot recover, throw an EJBException that wraps. 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…

Advanced Topics

Question

A session bean business method throws an exception during execution. Which two are responsibilities of the Bean Provider when throwing the exception? (Choose two.)

Options

  • AFor application exceptions, ensure that if the current transaction commits there will be no loss
  • BFor application exceptions, ensure that the current transaction will commit.
  • CFor system errors, when the client is remote through a java.rmi.remoteException that wraps the
  • DFor checked exceptions from which the bean cannot recover, throw an EJBException that wraps

How the community answered

(44 responses)
  • A
    80% (35)
  • B
    14% (6)
  • C
    7% (3)

Explanation

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.

Topics

#exception handling#application exceptions#EJBException#system errors

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice