Certification
SCBCD
SCBCD Study Notes : Chapter 12 : Exceptions (Part 1)
SCBCD Study Notes : Chapter 12 : Exceptions (Part 1) - Page 2Please find the Study Notes and resources which covers 1st Part of Chapter 12 : Exceptions, as part of the Sun Certified Business Component Developer exam CX-310-090.
Identify correct and incorrect statements or examples about exception handling in EJB.
1. Given a list of responsibilities related to exceptions, identify those which are the bean provider's, and those which are the responsibility of the container provider. Be prepared to recognize responsibilities for which neither the bean provider or the container provider are responsible.
2. Given a list of responsibilities related to exceptions, identify those which are the bean provider's, and those which are the responsibility of the container provider. Be prepared to recognize responsibilities for which neither the bean provider or the container provider are responsible.
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.
The Bean Provider defines the APPLICATION exceptions [BUSINESS exceptions] in the throws clauses of the methods of the home and component interfaces. Because application exceptions are intended to be handled by the CLIENT, and NOT by the SYSTEM administrator, they should be used only for reporting BUSINESS logic exceptions, NOT for reporting SYSTEM level problems.
The Bean Provider is responsible for throwing the appropriate APPLICATION exception from the business method to report a business logic exception to the client. Because the application exception DOES NOT automatically result in marking the transaction for rollback, the Bean Provider MUST do one of the following to ensure data integrity before throwing an application exception from an enterprise bean instance:
Next Page: SCBCD Study Notes : Chapter 12 : Exceptions (Part 1) - Page 2