You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Sean C. McCarthy" <sm...@itconsultores.com> on 2004/12/24 04:10:36 UTC

Problem with finalized connections

Hi All,

I'm having problems with OJB in an application we are developing. From 
time to time an exception is thrown by the finalizer thread of the VM:

[org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
No operations allowed after connection closed.

at com.mysql.jdbc.Connection.checkClosed(Connection.java:2474)
at com.mysql.jdbc.Connection.createStatement(Connection.java:1179)
at com.mysql.jdbc.Connection.createStatement(Connection.java:1198)
at 
org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl$ConPoolFactory.validateConnection(Unknown 
Source)
at 
org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl$ConPoolFactory.validateObject(Unknown 
Source)
at 
org.apache.commons.pool.impl.GenericObjectPool.returnObject(GenericObjectPool.java:900)
at 
org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl.returnConnectionToPool(Unknown 
Source)
at 
org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.releaseConnection(Unknown 
Source)
at 
org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.releaseConnection(Unknown 
Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.close(Unknown Source)
at org.apache.ojb.broker.core.PersistenceBrokerImpl.finalize(Unknown Source)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

The PersistenceBroker is released and everything seems to be working ok 
and the exception is not hurting the application, but I guess it's not 
right either.

My connection pool is configured as follows,

<connection-pool
   maxActive="21"
   maxIdle="-1"
   maxWait="1000"
   testOnBorrow="true"
   testOnReturn="true"
   validationQuery="SELECT 1"
   whenExhaustedAction="2"
/>

The section about validationQuery="SELECT 1" was added since the pool 
was returning closed connections.

What am I doing wrong? Thanks in advance,

	Sean C. McCarthy

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


Re: Problem with finalized connections

Posted by "Sean C. McCarthy" <sm...@itconsultores.com>.
Hi Armin,

Thanks a lot, we've been checking our source code and found a couple 
sections without a 'finally' block where exceptions were arising. These 
exceptions were preventing the code from returning the broker to the 
pool by closing it.

Thanks again,

	Sean C. McCarthy

Armin Waibel wrote:
> Hi Sean,
> 
> seems you have a PersistenceBroker leak. The finalizer method of PB 
> checks if the PB instance was closed, if not PB.close() was called. On 
> close the ConnectionManager try to release the used connection (call 
> release on ConnectionFactory). The ConnectionFactory try to validate the 
> connection (testOnReturn="true") but the connection was already closed 
> (assume it was timed out).
> 
> So this stack is ok when you shutdown a running OJB instance. If the 
> exception raise from time to time when running OJB it indicates a PB leak.
> 
> regards,
> Armin
> 
> Sean C. McCarthy wrote:
> 
>> Hi All,
>>
>> I'm having problems with OJB in an application we are developing. From 
>> time to time an exception is thrown by the finalizer thread of the VM:
>>
>> [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
>> No operations allowed after connection closed.
>>
>> at com.mysql.jdbc.Connection.checkClosed(Connection.java:2474)
>> at com.mysql.jdbc.Connection.createStatement(Connection.java:1179)
>> at com.mysql.jdbc.Connection.createStatement(Connection.java:1198)
>> at 
>> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl$ConPoolFactory.validateConnection(Unknown 
>> Source)
>> at 
>> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl$ConPoolFactory.validateObject(Unknown 
>> Source)
>> at 
>> org.apache.commons.pool.impl.GenericObjectPool.returnObject(GenericObjectPool.java:900) 
>>
>> at 
>> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl.returnConnectionToPool(Unknown 
>> Source)
>> at 
>> org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.releaseConnection(Unknown 
>> Source)
>> at 
>> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.releaseConnection(Unknown 
>> Source)
>> at org.apache.ojb.broker.core.PersistenceBrokerImpl.close(Unknown Source)
>> at org.apache.ojb.broker.core.PersistenceBrokerImpl.finalize(Unknown 
>> Source)
>> at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
>> at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
>> at java.lang.ref.Finalizer.access$100(Unknown Source)
>> at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
>>
>> The PersistenceBroker is released and everything seems to be working 
>> ok and the exception is not hurting the application, but I guess it's 
>> not right either.
>>
>> My connection pool is configured as follows,
>>
>> <connection-pool
>>   maxActive="21"
>>   maxIdle="-1"
>>   maxWait="1000"
>>   testOnBorrow="true"
>>   testOnReturn="true"
>>   validationQuery="SELECT 1"
>>   whenExhaustedAction="2"
>> />
>>
>> The section about validationQuery="SELECT 1" was added since the pool 
>> was returning closed connections.
>>
>> What am I doing wrong? Thanks in advance,
>>
>>     Sean C. McCarthy
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> .
> 


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


Re: Problem with finalized connections

Posted by Armin Waibel <ar...@apache.org>.
Hi Sean,

seems you have a PersistenceBroker leak. The finalizer method of PB 
checks if the PB instance was closed, if not PB.close() was called. On 
close the ConnectionManager try to release the used connection (call 
release on ConnectionFactory). The ConnectionFactory try to validate the 
connection (testOnReturn="true") but the connection was already closed 
(assume it was timed out).

So this stack is ok when you shutdown a running OJB instance. If the 
exception raise from time to time when running OJB it indicates a PB leak.

regards,
Armin

Sean C. McCarthy wrote:
> Hi All,
> 
> I'm having problems with OJB in an application we are developing. From 
> time to time an exception is thrown by the finalizer thread of the VM:
> 
> [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
> No operations allowed after connection closed.
> 
> at com.mysql.jdbc.Connection.checkClosed(Connection.java:2474)
> at com.mysql.jdbc.Connection.createStatement(Connection.java:1179)
> at com.mysql.jdbc.Connection.createStatement(Connection.java:1198)
> at 
> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl$ConPoolFactory.validateConnection(Unknown 
> Source)
> at 
> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl$ConPoolFactory.validateObject(Unknown 
> Source)
> at 
> org.apache.commons.pool.impl.GenericObjectPool.returnObject(GenericObjectPool.java:900) 
> 
> at 
> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl.returnConnectionToPool(Unknown 
> Source)
> at 
> org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.releaseConnection(Unknown 
> Source)
> at 
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.releaseConnection(Unknown 
> Source)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.close(Unknown Source)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.finalize(Unknown 
> Source)
> at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
> at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
> at java.lang.ref.Finalizer.access$100(Unknown Source)
> at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
> 
> The PersistenceBroker is released and everything seems to be working ok 
> and the exception is not hurting the application, but I guess it's not 
> right either.
> 
> My connection pool is configured as follows,
> 
> <connection-pool
>   maxActive="21"
>   maxIdle="-1"
>   maxWait="1000"
>   testOnBorrow="true"
>   testOnReturn="true"
>   validationQuery="SELECT 1"
>   whenExhaustedAction="2"
> />
> 
> The section about validationQuery="SELECT 1" was added since the pool 
> was returning closed connections.
> 
> What am I doing wrong? Thanks in advance,
> 
>     Sean C. McCarthy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

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