如何在WebLogic 8.1.6环境中查找有连接池泄漏的代码

解决连接池泄漏步骤

登录weblogicconsole,  %Domain% -> Services -> JDBC -> Connection Pools ->jdbc/ioa

Configuration -> Connection,点开AdvancedOptions,修改以下配置项状态:

 

配置项名称

默认值

修改为

说明

Enable Connection Leak Profiling

禁用

启用

开启连接池泄漏的监控。

Enable Connection Profiling

禁用

启用

开启连接池监控。

Inactive Connection Timeout

0

100

连接在指定时间内(单位:秒)没有活动的话,WebLogic会将之释放并回收到连接池。

 

    以上配置项修改后不影响在跑的应用,不需要重启服务器或应用(配置项前没有黄色小图标WebLogic很明确的告诉我们这个配置是不需要重启的),所以大可放心设置。只是启用监控后会对性能有一些影响,具体影响会有多大,我没有测试过,但开启这些设置只是暂时的,得到日志后我们就可以把配置还原会默认值。

在没有解决连接池泄漏问题之前,如果没有请求时连接池将一直保持为0,不会再有连接池满造成请求无法响应的问题,我们也不用担心再挨客户骂,也为我们解决问题争取了宝贵到时间。


好了,下面才是关键。


过一段时间后,在bea/user_projects/domains/%domainname%/%servername%目录下,打开%servername%.log,查找,"AJDBC pool connection leak was detected",如果WebLogic已经监控到有连接池泄漏的话,就可以找到以下日志,并且很清楚的告诉我们在哪一个类的哪行代码创建了连接,但没有关闭(注意红色加粗字体):


 

2008-5-22上午114720 CST      Warning    JDBC                A JDBC pool connection leak wasdetected. A connection leak occurs when a connection obtained from the pool wasnot closed explicitly by calling close() and then was disposed by the garbagecollector and returned to the connection pool. The following stack trace atcreate shows where the leaked connection was created. Stack trace at connectioncreate:

      atweblogic.jdbc.wrapper.PoolConnection.init(PoolConnection.java:75)

      atweblogic.jdbc.pool.Driver.allocateConnection(Driver.java:254)

      atweblogic.jdbc.pool.Driver.connect(Driver.java:84)

      atweblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)

      atweblogic.jdbc.jts.Driver.connect(Driver.java:140)

      atweblogic.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

 

……

      

 

      另外一种方法:

      WebLogicConsole,展开 %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.

 

 



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值