posted 15 years ago
It is the container providers's role to release managed resources in this situation, when discarding the bean instance. Of course, unmanaged resources cannot be dealt by the container.
In the core specification, about the bean provider's responsability for system exceptions (14.2.2 System Exceptions), it is stated that the Bean Provider does not have to perform any cleanup actions before throwing a non-application exception. It is the container that is responsible for the cleanup.
You'll find even more details at the "14.3.11 Release of Resources" section, about the Container's responsability : 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 16.7).
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.