EJB.12.1 Overview and Concepts


EJB.12.1.1 Application Exceptions

An application exception is an exception defined in the throws clause of a method of the enterprise bean's home and remote 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 (see Section EJB.9.1.9). These exceptions are covered by the rules on application exceptions that are defined in this chapter.

EJB.12.1.2 Goals for Exception Handling

The EJB specification for exception handling is designed to meet these high-level goals:

  • 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 roll back 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.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net