Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, v1.1 - Sun Microsystems.pdf
Скачиваний:
11
Добавлен:
24.05.2014
Размер:
1.62 Mб
Скачать

Sun Microsystems Inc.

Exception handling

Enterprise JavaBeans v1.1, Final Release

Container Provider responsibilities

12.3.5 Exceptions from the management of container-managed transactions

The container is responsible for starting and committing the container-managed transactions, as described in Subsection 11.6.2. This subsection specifies how the Container must deal with the exceptions that may be thrown by the transaction start and commit operations.

If the Container fails to start or commit a container-managed transaction, the Container must throw the java.rmi.RemoteException to the client.

However, the Container should not throw the java.rmi.RemoteException if the Container performs a transaction rollback because the instance has invoked the setRollbackOnly() method on its EJBContext object. In this case, the Container must rollback the transaction and pass the business method result or the application exception thrown by the business method to the client.

Note that some implementations of the Container may retry a failed transaction transparently to the client and enterprise bean code. Such a Container would throw the java.rmi.RemoteException after a number of unsuccessful tries.

12.3.6 Release of resources

When the Container discards an instance because of a system exception, the Container should release all the resources held by the instance that were acquired through the resource factories declared in the enterprise bean environment (See Subsection 14.4).

Note: While the Container should release the connections to the resource managers that the instance acquired through the resource factories declared in the enterprise bean environment, the Container cannot, in general, release “unmanaged” resources that the instance may have acquired through the JDK APIs. For example, if the instance has opened a TCP/IP connection, most Container implementations will not be able to release the connection. The connection will be eventually released by the JVM garbage collector mechanism.

12.3.7 Support for deprecated use of java.rmi.RemoteException

The EJB 1.0 specification allowed the business methods, ejbCreate, ejbPostCreate, ejbFind<METHOD>, ejbRemove, and the container-invoked callbacks (i.e. the methods defined in the EntityBean, SessionBean, and SessionSynchronization interfaces) implemented in the enterprise bean class to use the java.rmi.RemoteException to report non-application exceptions to the Container.

This use of the java.rmi.RemoteException is deprecated in EJB 1.1—enterprise beans written for the EJB 1.1 specification should use the javax.ejb.EJBException instead.

The EJB 1.1 specification requires that a Container support the deprecated use of the java.rmi.RemoteException. The Container should treat the java.rmi.RemoteException thrown by an enterprise bean method in the same way as it is specified for the javax.ejb.EJBException.

11/24/99

194