Detecting Connection Leaks in JBoss

Detecting Connection Leaks

JBoss has a CachedConnectionManager service that can be used to detect connection leaks (within the scope of a request)

Configured in ${jboss.server.url}/deploy/jbossjca-service.xml

Triggered by Tomcat’s server.xml→<Host>→CachedConnectionValve

Enabled by default - slight overhead

Should be used during testing

Can be turned off in production if the code is stable

If the CachedConnectionValve is enabled in Tomcat’s server.xml file, then Tomcat must wait for the CachedConnectionManager service on startup. This is accomplished by adding the following line to Tomcat’s META-INF/jboss-service.xml file (near the end):


Learn the core features of JBOSS Traning and become master with our expertise tutorials.

Connection pools could be monitored (through JMX) by looking at jboss.jca:name=MyDS,service=ManagedConnectionPool→InUseConnectionCount attribute.

The example web application northwind.war can be made to leak resources (on /ListCustomers) by

appending requesting /ListCustomers?leak=true, and/or by

adding a custom system property: -Dleak.jdbc.resources=true to JAVA_OPTS in run.conf or run.bat (on Windows)

For indepth understanding on JBoss click on: