使用Datasource强制释放weblogic中的非活动/收获连接

时间:2015-08-27 13:14:26

标签: hibernate jdbc weblogic connection-pooling

我创建了一个在DB中更改表的简单项目。我正在使用weblogic服务器10.3和Hibernate(hibernate-core-4.1.0.jar)进行jdbc连接。我在weblogic中创建了Datasource(oracle.jdbc.xa.client.OracleXADataSource),用于连接池。当我执行我的程序后发生错误 -

<Forcibly releasing inactive/harvested connection "[weblogic.jdbc.wrapper.JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection-OBP_HOST_DS_XA-7306, oracle.jdbc.driver.LogicalConnection@23b35381]" back into the data source connection pool "OBP_HOST_DS_XA", currently reserved by: java.lang.Exception
    at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:366)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:373)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:339)
    at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:469)
    at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:363)
    at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:125)
    at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:77)
    at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1791)
    at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1582)
    at weblogic.jdbc.jta.DataSource.getConnectionInternal(DataSource.java:499)
    at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:483)
    at weblogic.jdbc.common.internal.RmiDataSource.getConnectionInternal(RmiDataSource.java:527)
    at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:513)
    at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:506)
    at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)
    at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:277)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
    at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82)
    at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    at com.sun.proxy.$Proxy180.getMetaData(Unknown Source)
    at com.splwg.base.support.context.ApplicationContext$3.execute(ApplicationContext.java:633)
    at org.hibernate.jdbc.WorkExecutor.executeWork(WorkExecutor.java:54)
    at org.hibernate.internal.SessionImpl$1.accept(SessionImpl.java:1850)

用3.6版本替换Hibernate Jars 4.1时,同一程序没有错误。 当使用UCP(Oracle Universal Connection)连接池而不是DataSource时,同样的程序也在工作。 使用Hibernate 4.1 jars时要做的配置是什么?

1 个答案:

答案 0 :(得分:0)

您已泄露连接。没关闭它。它变得不活跃,但不在池中。一段时间后,WLS注意到连接实际上是不活动的,即泄漏,并强行关闭它,将其返回池中。

参考

Force release the connection in weblogic 10.3.4

GMREYES