aspose file tools*
The moose likes JDBC and the fly likes Connection leak exception. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection leak exception." Watch "Connection leak exception." New topic
Author

Connection leak exception.

Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Hi,
I one of my applications deployed in weblogic application server. I often get connection leak warning message on server console (though my application flow is not affected by this warning message).
I have to investigate the cause for the connection leak, first thing I have made sure is all opened connection are close correctly with in the code, still I keep getting this warning message...
What would be the other possible cause for this warning message?
Thanks in advance.
Regards
Arun


Sharing is learning
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Speaking generally (I don't know how weblogic detects leaks), you get a connection leak warning because you're leaking connections, often because the exception handling is wrong and connections aren't getting closed sometimes when exceptions occur, but sometimes because there's another type of code path that hasn't been considered. Mostly, when developers think they aren't leaking connections and something else is the problem, they're wrong. Really.

However, some leak detecters will mistake a connection that's not leaked but has been checked out of a pool for longer than a threshhold value as a leak. In some cases, adjusting the leak time threshold is the fix; sometimes setting a "short operation" pool and a much smaller "long operation" pool is right; sometimes a really long running background thread shouldn't be getting its connection from a pool at all.
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Hi,
I get following message on weblogic console, I am not able to co-relate with the application code, since in application connection close is taken care off.

<Mar 13, 2006 1:07:21 AM CST> <Warning> <JDBC> <BEA-001074> <A JDBC pool connection leak was detected. A connection leak occurs when
a connection obtained from the pool was not closed explicitly by calling close() and then was disposed by the garbage collector and
returned to the connection pool. The following stack trace at create shows where the leaked connection was created. [Null exceptio
n passed, creating stack trace for offending caller]
at weblogic.utils.StackTraceUtils.throwable2StackTrace(StackTraceUtils.java:28)
at weblogic.jdbc.wrapper.PoolConnection.finalize(PoolConnection.java:77)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)


Can any one give some light on this problem.
Thanks
Arun
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Your code is definitely leaking connections.

That stack trace tells us exactly how weblogic is detecting leaks, and it's a technique that will never ever ever falsely report a leak. However, for a short run of a JVM, it might fail to report a leak, when the leaked connection isn't garbage colleced before the JVM stops.

What is happening is that the pool is returning wrapped connections; the wrapper object is weblogic.jdbc.wrapper.PoolConnection. That object has a finalize method. Finalize methods for each object, if the method exists, are invoked during Garbage Collection, just before the object is destroyed. The finalize method of weblogic.jdbc.wrapper.PoolConnection tests whether the connection is open or not; if it is the error is logged.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Post your code and we'll try and find out why it is leaking conections.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection leak exception.
 
Similar Threads
Idle Java Application - Memory Leak?
Weblogic 8.1 SP5 server got shutdown due to Connection leak and java.lang.OutofMemory
Logging in Tomcat Server
Logging in Tomcat Server
Continuous Error in Server Log