weblogicConnection Leak 连接池泄漏问题解决 

当WebLogic遇到连接池泄漏时,可通过修改域配置启用连接泄漏监控和连接池监控,无需重启服务器。在日志中寻找'A JDBC pool connection leak was detected',通过堆栈跟踪定位未关闭的连接创建位置,从而修复程序bug,解决连接池泄漏问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

默认weblogic是不记录这个泄漏日志的,只会报jdbc 错误。
以下内容部分转载,部分是实际遇到,但解决步骤雷同,原文地址: http://blog.youkuaiyun.com/esky2000/archive/2008/07/22/2689929.aspx
1、修改
登录weblogic console,  %Domain% -> Services -> JDBC -> Connection Pools -> jdbc/ioa
Configuration页 -> Connection, 点开Advanced Options, 修改以下配置项状态:
配置项名称
 默认值
 修改为
 说明
Enable Connection Leak Profiling
 禁用
 启用
 开启连接池泄漏的监控。
Enable Connection Profiling
 禁用
 启用
 开启连接池监控。
Inactive Connection Timeout
 0
 100
 连接在指定时间内(单位:秒)没有活动的话,WebLogic会将之释放并回收到连接池。
2、 以上配置项修改后不影响在跑的应用,不需要重启服务器或应用(配置项前没有黄色小图标 <!--[if !vml]--><!--[endif]-->,WebLogic很明确的告诉我们这个配置是不需要重启的),所以大可放心设置。只是启用监控后会对性能有一些影响,具体影响会有多大,我没有测试过,但开启这些设置只是暂时的,得到日志后我们就可以把配置还原会默认值。
在没有解决连接池泄漏问题之前,如果没有请求时连接池将一直保持为0,不会再有连接池满造成请求无法响应的问题,我们也不用担心再挨客户骂,也为我们解决问题争取了宝贵到时间。
       好了,下面才是关键。
       过一段时间后,在bea/user_projects/domains/%domainname%/%servername%目录下,打开%servername%.log,查找,"A JDBC pool connection leak was detected",如果WebLogic已经监控到有连接池泄漏的话,就可以找到以下日志,并且很清楚的告诉我们在哪一个类的哪行代码创建了连接,但没有关闭(注意红色加粗字体):
2008-5-22 上午11时47分20秒 CST       Warning     JDBC                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. Stack trace at connection create:
       at weblogic.jdbc.wrapper.PoolConnection.init(PoolConnection.java:75)
       at weblogic.jdbc.pool.Driver.allocateConnection(Driver.java:254)
       at weblogic.jdbc.pool.Driver.connect(Driver.java:84)
       at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)
       at weblogic.jdbc.jts.Driver.connect(Driver.java:140)
       at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
       at com.cp.fw.dao.BaseDAO.getConnection(BaseDAO.java:78)
       at com.cp.fw.dao.dataset.DataSetOp.init(DataSetOp.java:78)
       at com.cp.fw.dao.dataset.DataSetOp.<init>(DataSetOp.java:45)
       at com.cp.ia.util.WorkFlowUtil.getNextWrokFlowId(WorkFlowUtil.java:93)
       at
 
       另外一种方法:
在WebLogic Console,展开 %DomainName% -> Servers -> %ServerName%,选到Logging – Server页,在页面最下方点击 "View server log",同样查找 "A JDBC pool connection leak was detected",也可以找到同样的日志。
WebLogic对于日志事件的说明:
Message ID
BEA-001074
Subsystem
 JDBC
Message
 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.  Stack trace at
connection create:
Detail
 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. A
stack trace is printed indicating where the leaked
connection was created.
Cause
 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. A
stack trace is printed indicating where the leaked
connection was created.
Action
 Close the connection appropriately
通过前面的一些操作,我们可以检查到我们程序的bug,通过修正bug,我们最终可以解决连接池泄漏问题~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值