3

我们有一个 Oracle 11g 数据库,一个使用休眠的 Web 服务。我们最近切换到 BoneCP 进行连接池,但似乎出现了问题,并且 BoneCP 在软件启动过程中关闭。

这是 hibernate.cfg 文件:

<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.password">pass</property>
    <property name="hibernate.connection.url">url/property>
    <property name="hibernate.connection.username">user</property>
    <property name="hibernate.default_schema">SYSTEM</property>
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
    <property name="hibernate.connection.defaultNChar">true</property>
    <property name="hibernate.connection.writedelay">0</property>
    <property name="hbm2ddl.auto">update</property>
    <property name="show_sql">true</property>

    <property name="bonecp.partitionCount">1</property>
    <property name="bonecp.maxConnectionsPerPartition">45</property>
    <property name="bonecp.minConnectionsPerPartition">10</property>
    <property name="bonecp.acquireIncrement">10</property>
    <property name="bonecp.idleConnectionTestPeriodInMinutes">1</property>
    <property name="bonecp.idleMaxAgeInMinutes">10</property>
    <property name="bonecp.idleConnectionTestPeriod">60</property>
    <property name="bonecp.poolAvailabilityThreshold">5</property>
    <property name="bonecp.partitionCount">1</property>
    <property name="bonecp.acquireIncrement">3</property>
    <property name="bonecp.releaseHelperThreads">3</property>
    <property name="bonecp.connectionTestStatement">SELECT 1</property>
    <property name="connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</property>
</session-factory>
</hibernate-configuration> 

在软件启动时,将执行三个查询,但在第三个查询有机会执行之前,BoneCP 似乎正在关闭,日志文件中有以下行:

SEVERE: [http-thread-pool-8080(5)] INFO com.jolbox.bonecp.BoneCP - Shutting down connection pool...

这是相关的堆栈跟踪:

org.hibernate.util.JDBCExceptionReporter|_ThreadID=100;_ThreadName=Thread-2;|Attempting to obtain a connection from a pool that has already been shutdown. 
Stack trace of location where pool was shutdown follows:
 java.lang.Thread.getStackTrace(Thread.java:1567)
 com.jolbox.bonecp.BoneCP.captureStackTrace(BoneCP.java:543)
 com.jolbox.bonecp.BoneCP.shutdown(BoneCP.java:159)
 com.jolbox.bonecp.provider.BoneCPConnectionProvider.close(BoneCPConnectionProvider.java:77)
 org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:175)
 org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
 org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
 data.ContractManagerUnitOfWork.createSession(ContractManagerUnitOfWork.java:166)
 data.ContractManagerUnitOfWork.<init>(ContractManagerUnitOfWork.java:36)
 data.UnitOfWorkFactory.createContractManagerUnitOfWork(UnitOfWorkFactory.java:10)
 controller.contractManager.ContractController.getCount(ContractController.java:112)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 java.lang.reflect.Method.invoke(Method.java:601)
 com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
 com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
 com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
 com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
 com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
 com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
 com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
 com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
 com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
 com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
 com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
 com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
 com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
 org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
 org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
 org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
 com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
 com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
 com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
 com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
 com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
 com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
 com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
 com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
 com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
 com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
 com.sun.grizzly.ContextTask.run(ContextTask.java:71)
 com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
 com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
 java.lang.Thread.run(Thread.java:722)

我们正在使用 bonecp-0.7.1.RELEASE.jar、bonecp-provider-0.7.1.RELEASE.jar 和 guava-14.0.1.jar。

4

1 回答 1

0

来自:com.jolbox.bonecp.provider.BoneCPConnectionProvider.close

这意味着池下面的层显式调用关闭,因此您的问题出在其他地方。

于 2013-04-28T18:17:22.213 回答