JBOSS AS 7.1.1.Final Closing Leaked Connections?

12,795

Solution 1

JBoss can not close all leaked connection.

You need to find leaked connection by checking logs after enabling JCA logging. I resolved connection leak by this way.

<logger category="org.jboss.jca">
                <level name="DEBUG"/>
</logger>

You will get entries like below in logs

DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-4) {JNDI_NAME}: getConnection(null, null) [1/100] --> It means taking connection from pool.

DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-4) {JNDI_NAME}: returnConnection(607e334, false) [1/99] --> It means returning connection to pool

You can check which query is not returning connetion to pool and check your application from where that query is being executed. Fix it.

Solution 2

A bit more information to Neeraj's answer.

DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-4) {JNDI_NAME}: getConnection(null, null) [1/100]

The [1/100] at the end is [active connections/available connections] where:

active connections = createdCount - destroyedCount

available connections = maxPoolSize - inUseCount 
Share:
12,795
Ashish Kataria
Author by

Ashish Kataria

Software Developer Bachelor's of Enginnering (Computer Science) - August 2008 Worked on various platforms and technologies like JAVA, C#, PL/Sql, IBM AS/400 Interested to provide solutions to arduous problems :)

Updated on June 05, 2022

Comments

  • Ashish Kataria
    Ashish Kataria almost 2 years

    I have already done the following settings in standalone.xml as:

    <datasource jta="true" jndi-name="java:jboss/datasources/myDS" pool-name="java:jboss/datasources/myDS" enabled="true" use-ccm="true">
    <cached-connection-manager debug="true" error="true"/>
    

    Therefore, I am also getting the messages like "Closing a connection for you" as:

    INFO  [org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager] (http--0.0.0.0-8080-160) IJ000100: Closing a connection for you. Please close them yourself: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@5cdb81dc: java.lang.Throwable: STACKTRACE
        at org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.registerConnection(CachedConnectionManagerImpl.java:265)
        at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:495)
        at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)
    

    Still, Sometimes my pool gets exhausted. It runs out of connections beyond 200 as defined. Why?

    <min-pool-size>30</min-pool-size>
    <max-pool-size>200</max-pool-size>
    

    There is no way, that my application needs these much connections. There is surely a connection leakage. And If it is, Why jboss is not closing it by it's own when I have enabled the setting as i said above:

    <datasource jta="true" jndi-name="java:jboss/datasources/myDS" pool-name="java:jboss/datasources/myDS" enabled="true" use-ccm="true">
    <cached-connection-manager debug="true" error="true"/>
    

    How to resolve?

    Thanks.

  • Ashish Kataria
    Ashish Kataria over 9 years
    How to see the unclosed connections along with their Stacktrace, the listinUseConnections() method from the CachedConnectionManager MBean which can be invoked from the JMX-console. How to see this in Jboss AS 7.1.1 ?
  • Neeraj
    Neeraj over 9 years
    CachedConnectionManager doesn't have listinUseConnections() method in AS 7. Remove error=true from <cached-connection-manager debug="true" error="true"/>
  • Neeraj
    Neeraj over 9 years
    Patch you can find patch here to see listinUseConnection() method.
  • Neeraj
    Neeraj over 9 years
    I am not very sure about compiled classes because I never used this. But You may get from later version of server.
  • Simo Erkinheimo
    Simo Erkinheimo almost 8 years
    This is not an answer to the original question. If this information has value, it should be edited into the referenced answer.
  • bkelly1984
    bkelly1984 over 7 years
    Agreed but I am a new user and don't have enough reputation to do so.