Special Edition Using Enterprise JavaBeans 2.0
Exceptions
Although exception handling is covered in detail in Chapter 13, basic exception information is provided here for your convenience. Figure A.2 shows you a UML diagram of the EJB exceptions and their relationships. Figure A.2. A UML diagram representing the EJB exception hierarchy.
Note All the EJB exceptions declare a no-argument constructor and one that accepts a String message.
AccessLocalException
An AccessLocalException is thrown to indicate that the caller does not have permission to call the method. This exception is thrown to local clients . CreateException
The CreateException exception must be included in the throws clauses of all create methods defined in an enterprise bean's component interface. DuplicateKeyException
The DuplicateKeyException exception is thrown if an entity EJB object cannot be created because an object with the same key already exists. EJBException
The EJBException exception is thrown by an enterprise bean instance to its container to report that the invoked business method or callback method could not be completed because of an unexpected error.
Note EJBException also declares a constructor that takes an Exception as the single argument. With this constructor, you can declare an EJBException that wraps another exception.
FinderException
The FinderException exception must be included in the throws clause of every find method of an entity bean's home interface. NoSuchEntityException
The NoSuchEntityException exception is thrown by an enterprise bean instance to its container to report that the invoked business method or callback method could not be completed because the underlying entity was removed from the database. This exception can be thrown by the bean class methods that implement the business methods defined in the bean's remote interface and also by the ejbLoad and ejbStore methods.
Note NoSuchEntityException also declares a constructor that takes an Exception as the single argument. With this constructor, you can create a NoSuchEntityException that wraps another exception.
NoSuchObjectLocalException
A NoSuchObjectLocalException is thrown if an attempt is made to invoke a method on a local object that no longer exists. ObjectNotFoundException
The ObjectNotFoundException exception is thrown by a single object finder method to indicate that the specified EJB object does not exist. RemoveException
The RemoveException exception is thrown at an attempt to remove an EJB object when the enterprise bean or the container does not allow the EJB object to be removed. TransactionRequiredLocalException
This exception indicates that a request carried a null transaction context, but the target object requires an activate transaction. TransactionRolledbackLocalException
This exception indicates that the transaction associated with processing of the request has been rolled back, or marked to roll back. Thus, the requested operation either could not be performed or was not performed because further computation on behalf of the transaction is not necessary. |