Leon Feijtel [
https://community.jboss.org/people/feijtel] created the document:
"javax.resource.ResourceException: Some connections were not closed"
To view the document, visit:
https://community.jboss.org/docs/DOC-17543
--------------------------------------------------------------
Hi,
Yesterday I was investigating a “Connection is not associated with a managed connection”
error that occurred in our application. Browsing through the log files, I discovered that
we accidentally leaked a connection when retrieving data from the database failed.
The following happened:
A ClassCastException occurred while Hibernate was resolving a ManyToOne relationship. One
of the classes involved was not Serializable. Because the error handling in our
application did not close the session, JBoss cleaned up for us and the
CachedConnectionManager reported: Closing a connection for you. Please close them
yourself.
Obviously, this means there are two errors in the application. One of the classes needed
to be Serializable, and our error handling wasn’t closing the session properly.
However, straight after that another error was shown in the logging:
1. javax.servlet.ServletException: Error invoking cached connection manager
at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:174)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.resource.ResourceException: Some connections were not closed, see the log
for the allocation stacktraces
at
org.jboss.resource.connectionmanager.CachedConnectionManager.popMetaAwareObject(CachedConnectionManager.java:251)
at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:164)
... 6 more
This confuses me a little. JBoss detects that we left a connection open (we have the
properties ‘debug’ and ‘error’ both set to true in the jca-jboss-beans.xml), but it seems
that when JBoss tries to close it, something else goes wrong. Why closing fails, I do not
know. The ResourceException says “see the log file for allocation stacktraces”, but I’m
not sure what to look for?
After all of the above, the Hibernate Session object thinks its session object and
connection are still in good shape. The session.isOpen() and the session.isConnected()
both return true. However, the underlying JDBC connection isn’t there anymore. Any attempt
to use the Session object afterwards results in the “Connection is not associated with a
managed connection” error mentioned above.
We are using JBoss 5 and Hibernate 3.2. We plan to upgrade Hibernate to a new version, but
haven’t been able to find the time. So I'm stuck for now with this version.
I realize our application contains a serious error by not closing the session, and that
that is the area that needs to be fixed. But I’m trying to understand how it’s possible
that closing the connection fails and how it’s possible that Hibernate still thinks
everything is ok, while the underlying JDBC connection has been closed/destroyed.
Shouldn't JBoss signal that the connection close failed and inform Hibernate?
Any help is appreciated.
--------------------------------------------------------------
Comment by going to Community
[
https://community.jboss.org/docs/DOC-17543]
Create a new document in Datasource Configuration at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=102&a...]