You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Fedor Karpelevitch <fe...@mscibarra.com> on 2005/08/10 22:21:53 UTC

[dbcp] NullPointerException retrieving connection from the pool

Hi.

I filed this bug a while ago, but did not get any reaction.
Do you guys think my diagnosis of the problem is correct?

------------------------

under some load we start getting this exception when retrieving connection
from
pool:

org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection
info
from pool
        at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnection
AndInfo(SharedPoolDataSource.java:169)
        at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst
anceKeyDataSource.java:631)
        at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst
anceKeyDataSource.java:615)
        at
org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:705)
        ... 34 more
Caused by: java.lang.NullPointerException
        at
org.apache.commons.collections.SequencedHashMap.insertEntry(SequencedHashMap
.java:226)
        at
org.apache.commons.collections.SequencedHashMap.put(SequencedHashMap.java:45
1)
        at org.apache.commons.collections.LRUMap.put(LRUMap.java:125)
        at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getUserPassKey(Shar
edPoolDataSource.java:179)
        at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnection
AndInfo(SharedPoolDataSource.java:165)
        ... 37 more

this is apparently caused by improper syncronization:

SharedPoolDataSource.getPooledConnectionAndInfo() is synchronized _instance_
method, but it accesses SharedPoolDataSource.userKeys which is a _static_
variable, so if you have more than one instance of SharedPoolDataSource (as
we
do) access to the map would not be properly synchronized. So either map
should
be made instance variable, or the method should be synchronized on the
class,
not instance.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org