Chapter 12. Exceptions

Identify correct and incorrect statements or examples about exception handling in EJB.

An APPLICATION EXCEPTION is an exception defined in the throws clause of a method of the enterprise Bean's home and component interfaces, other than the java.rmi.RemoteException.

Enterprise bean business methods use APPLICATION exceptions to inform the client of abnormal application-level conditions, such as unacceptable values of the input arguments to a business method. A client can typically recover from an application exception. Application exceptions are not intended for reporting system-level problems.

For example, the Account enterprise bean may throw an application exception to report that a debit operation cannot be performed because of an insufficient balance. The Account bean should NOT use an application exception to report, for example, the failure to obtain a database connection.

The javax.ejb.CreateException, javax.ejb.RemoveException, javax.ejb.FinderException, and subclasses thereof are considered to be application exceptions. These exceptions are used as standard application exceptions to report errors to the client from the create, remove, and finder methods.

An application exception class MUST be a subclass (direct or indirect) of java.lang.Exception. An application exception class MUST NOT be defined as a subclass of the java.lang.RuntimeException OR of the java.rmi.RemoteException.

An APPLICATION exception thrown by an enterprise bean instance should be reported to the client PRECISELY (i.e., the client gets THE SAME exception).

An application exception thrown by an enterprise bean instance should NOT automatically rollback a client's transaction. The client should typically be given a chance to recover a transaction from an application exception.

An unexpected exception that may have left the instance's state variables and/or underlying persistent data in an inconsistent state can be handled safely.

Professional hosting     Belorussian informational portal         Free SCWCD 1.4 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide     Free Mock Exam Engine