Sunday, August 30, 2009

A potential connection leak detected for connection pool

i got followwing exception in Sun Java System Application Server (GlassFish)
A potential connection leak detected for connection pool . The stack trace of the thread is provided below :com.sun.enterprise.resource.AbstractResourcePool.startConnectionLeakTracing(AbstractResourcePool.java:310)com.sun.enterprise.resource.AbstractResourcePool.setResourceStateToBusy(AbstractResourcePool.java:301)com.sun.enterprise.resource.AbstractResourcePool.getResourceFromPool(AbstractResourcePool.java:778)com.sun.enterprise.resource.AbstractResourcePool.getUnenlistedResource(AbstractResourcePool.java:652)com.sun.enterprise.resource.AbstractResourcePool.internalGetResource(AbstractResourcePool.java:594)com.sun.enterprise.resource.AbstractResourcePool.getResource(AbstractResourcePool.java:443)com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:248)com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java:176)com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:327)com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:235)
i overcome this with by following changes in Connection Pool settings




6 comments:

Jim Cullison said...

If you do that you are just covering up a real problem. The problem will come back to bite you. The connection leak detection is friend, turn it back on!

You need to look at the stack trace the leak detection gave you. Your code (or someone else's) is not calling .close() on a connection it pulled from the pool in time.

For example (DON'T DO THIS, IT LEAKS):
InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/my_db");

Connection con = ds.getConnection(); //to fix this, put this getConnection inside the try block, seems obvious, but I found a similar problem in "production" code

try {
Statement st = con.prepareStatement("update blah...");
st.executeUpdate(); //if this fails for any reason, the connection will NOT be returned to the pool
} finally {
con.close();
}

Milliscent Morgan said...

Hi, glad that I found this helpful and relevant blogsite about gas leak detection, try to keep on posting!-gas leak detection San Jose CA-

jowdjbrown said...

You need to look at the stack trace the leak detection gave you. Your code (or someone else's) is not calling .close() on a connection it pulled from the pool in time.See My Page

Erik M Tammaru said...

Jim Cullison,

thank you for the example! I have production code which does exactly that and was seeing potential connection leak warnings! I am very grateful for your work/example. . .

Dave Smith said...

Hi, Thanks for the info. My inground Pool Is Leaking. My plan is to just wait and see where the water stops at. however, if the leak is at the bottom (a crack i have not found) is there a risk of the pool popping out of the ground? would i have to drill relief holes? how low can the pool drain before it could pop out of the ground?

roney ahmed said...

يعتبر رش المبيد من الامور الصعبه التى لابد ان تتم
مكافحة حشرات بالمدينة المنورة
بحرص شديد جدا شركة مكافحة الحشرات بالمدينة المنورة تقوم باعمال الرش من خلال اقوى انواع المبيدات الحشرية المتواجده فى الاسواق والاعتماد على افضل انواع الرش من الرش الالمانى
مكافحة الحشرات بالمدينة المنورة
وطرق الرش بالحقن والقيام برش الاسطح بالمبيدات وتستمرما يقرب من 6 ساعات متواصل والقيام باعمال المسح على الفور وتاكد انك لم تستطيع ان تتعرض الى الحشرات
رش حشرات بالمدينة المنورة
مره اخرى كما ان شركة مكافحة حشرات تعتمد على اجود انواع المبيدات التى تساعد فى القيام باعمال الرش دون ان تترك اى اثر للحشرات ويمتد مفعول المبيد الى ما يقرب من 10- 15 سنه تقريبا.