标签:lis 开始 this provider apache 没有 网站 waiting dbcp
最近段时间。今年开始把。我维护的网站一直报错数据库连接不上,找不到链接,连接池耗尽问题。
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
2017-07-26 15:42:20,516 ERROR [STDERR] at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
2017-07-26 15:42:20,516 ERROR [STDERR] at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
2017-07-26 15:42:20,516 ERROR [STDERR] at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
2017-07-26 15:42:20,516 ERROR [STDERR] at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
2017-07-26 15:42:20,516 ERROR [STDERR] at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
2017-07-26 15:42:20,516 ERROR [STDERR] at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.loader.Loader.doQuery(Loader.java:673)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
2017-07-26 15:42:20,531 ERROR [STDERR] at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
2017-07-26 15:42:20,547 ERROR [STDERR] at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
2017-07-26 15:42:20,547 ERROR [STDERR] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
2017-07-26 15:42:20,547 ERROR [STDERR] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
2017-07-26 15:42:20,547 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:477)
2017-07-26 15:42:20,547 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
2017-07-26 15:42:20,547 ERROR [STDERR] ... 68 more
2017-07-26 15:42:20,547 ERROR [STDERR] Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
2017-07-26 15:42:20,547 ERROR [STDERR] at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:756)
大概日志如上所示,很是郁闷,叫来了测试。想让测试找出根源。结果测试只能重现错误。。我瞬间感觉失去信心了。
后面好好看看日志,看看报错方法,发现dao里获取connection竟然是this.getSession。后面百度了下这个方法。是hibernate自带的,但不会释放。对比了几个获取方式,我小心翼翼的替换了几个类。害怕不是根源。。
后面让测试再次测试了后。发现没有报错连接池耗尽之类的问题。。
暂时这么处理了。后续在继续观察中。大家有更好的见解可以提出。
标签:lis 开始 this provider apache 没有 网站 waiting dbcp
原文地址:https://www.cnblogs.com/wuyachal/p/9037323.html