Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-225

getConnection / borrowObject fails with NullPointerException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1, 1.2.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      Solaris 10, Oracle 10g RAC

      Description

      We use dbcp PoolingDataSource in Solaris/Oracle 10g RAC environment and our getConnection calls fail sporadically with the following stack trace (1.2.1)

      Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
      at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
      ... more
      Caused by: java.util.NoSuchElementException: Could not create a validated object, cause: null
      at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:806)
      at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
      ... 24 more

      This is definitely not a "pool exhausted" situation, it is just being reported as pool exhausted. Since NoSuchElementException that you use does not allow cause, only Exception message (null) is being printed. With some debugging I was able to recover the root exception:

      java.lang.NullPointerException
      at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:268)
      at org.apache.commons.dbcp.PoolableConnectionFactory.activateObject(PoolableConnectionFactory.java:368)
      at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:786)
      at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
      ...

      Looks like it is trying to borrow/validate DelegatingConnection which delegate is null.

      Hoping to resolve the issue we upgraded to 1.2.2 but it did not help. Here is is an exception stack trace from 1.2.2:

      org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Could not create a validated object, cause: null
      at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:104)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
      ... more
      Caused by: java.util.NoSuchElementException: Could not create a validated object, cause: null
      at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:871)
      at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96)
      ... 28 more

      We use the following dbcp properties:

      autoCommit="false"
      readOnly="false"
      maxActive="200"
      maxIdle="20"
      minIdle="10"
      minEvictableIdleIime="300000"
      maxWait="200"
      accessToUnderlyingConnectionAllowed="true"
      validationQuery="SELECT 1 FROM DUAL"
      ConnectionCachingEnabled="true"
      FastConnectionFailoverEnabled="true"

      I could not find the existing reported dbcp/object pool bug but I see similar reports on the web, for example
      http://forum.java.sun.com/thread.jspa?threadID=713200&messageID=4124915

        Attachments

        1. DBCP-225.patch
          2 kB
          Dain Sundstrom

          Issue Links

            Activity

              People

              • Assignee:
                dain Dain Sundstrom
                Reporter:
                asamonov Alexei Samonov
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: