hi again,
thanks for the answer. I looked at the random connection closed exceptions
but I'm correctly closing my connections. I've attached a stacktrace that
happen later, sorry, it was of course less obvious to figure out like
that... Here is the first exception I have:
Thread [pool-5-thread-4] (Suspended (exception IllegalStateException))
KeyedCPDSConnectionFactory.connectionClosed(ConnectionEvent) line:
265
SybPooledConnection.notifyListeners(SQLException) line: 225
SybConnectionProxy.close() line: 106
SybPooledConnection.close() line: 166
KeyedCPDSConnectionFactory.destroyObject(Object, Object) line: 175
GenericKeyedObjectPool.returnObject(Object, Object) line: 997
KeyedCPDSConnectionFactory.connectionClosed(ConnectionEvent) line:
268
SybPooledConnection.notifyListeners(SQLException) line: 225
SybConnectionProxy.close() line: 106
... (i'm calling close on the SQL Connection here, when the thread
is finished)
After analyzing it a bit I understand the pool wants to destroy the object
because my pool can not support any more idle connection (I'm at the point
where active=maxActive=maxIdle=5).
What I do not understand is why the destroyObject method does:
public void destroyObject(Object key, Object obj) throws Exception {
if (obj instanceof PooledConnectionAndInfo) {
PooledConnection pc =
((PooledConnectionAndInfo)obj).getPooledConnection();
pcMap.remove(pc);
pc.close();
}
}
Which means it removes the mapping and close the PooledConnection. At this
point, the listener is still active and it calls the listener which will
obviously fail:
public void connectionClosed(ConnectionEvent event) {
PooledConnection pc = (PooledConnection)event.getSource();
// if this event occured becase we were validating, ignore it
// otherwise return the connection to the pool.
if (!validatingMap.containsKey(pc)) {
PooledConnectionAndInfo info =
(PooledConnectionAndInfo) pcMap.get(pc);
if (info == null) {
throw new IllegalStateException(NO_KEY_MESSAGE); //
<--------- the Exception which is thrown
}
...
Isn't this http://issues.apache.org/jira/browse/DBCP-216? Or maybe the
driver should not notify for both the Connection and PooledConnection
close?
Do you have any solution?
Thanks you for your patience :)
best regards,
--Stéphane
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
gives a discussion of "Random Connection closed Exceptions" which may help
you.
mas
[EMAIL PROTECTED] wrote:
Hi all !
I'm using a SharedDataPool and when I try to close the Connection to
return it to the pool at some point, I get the following exception:
Exception in thread "pool-7-thread-1" java.lang.IllegalStateException:
close() was called on a Connection, but I have no record of the underlying
PooledConnection. at
org.apache.commons.dbcp.datasources.KeyedCPDSConnectionFactory.connectionClosed(KeyedCPDSConnectionFactory.java:265)
at
com.sybase.jdbc2.jdbc.SybPooledConnection.notifyListeners(SybPooledConnection.java:225)
at
com.sybase.jdbc2.jdbc.SybConnectionProxy.close(SybConnectionProxy.java:106)
at
com.sybase.jdbc2.jdbc.SybPooledConnection.reAssignProxy(SybPooledConnection.java:246)
at
com.sybase.jdbc2.jdbc.SybPooledConnection.getConnection(SybPooledConnection.java:106)
at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:691)
at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:653)
I use dbcp-1.2.2 with sybase jConnect 6.05 and I don't understand the
problem ... who is the culprit: the driver, dbcp or me? If I do not return
this connection to the pool, I'm endin up quickly without any connection
left :-/
Thanks for helping me.
Best regards,
--Stéphane
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.