简体   繁体   English

Hibernate和C3p0池的问题

[英]Issues with Hibernate and C3p0 pool

I'm testing web application with hibernate 4.3.0 and c3p0 pool and sometimes after reloading context I get this error: 我正在使用hibernate 4.3.0和c3p0池测试Web应用程序,有时在重新加载上下文后我收到此错误:

 INFO: Reloading Context with name [/AppName] is completed
    янв 07, 2015 12:07:14 AM org.apache.catalina.loader.WebappClassLoader loadClass
    INFO: Illegal access: this web application instance has been stopped already.  Could not load com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
    java.lang.IllegalStateException
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
        at com.mchange.v2.resourcepool.BasicResourcePool.checkIdleResources(BasicResourcePool.java:1584)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$2000(BasicResourcePool.java:44)
        at com.mchange.v2.resourcepool.BasicResourcePool$CheckIdleResourcesTask.run(BasicResourcePool.java:2116)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)

Exception in thread "C3P0PooledConnectionPoolManager[identityToken->1hge136961hmilhm17ylc97|17d425e]-AdminTaskTimer" java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$AsyncTestIdleResourceTask
    at com.mchange.v2.resourcepool.BasicResourcePool.checkIdleResources(BasicResourcePool.java:1584)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$2000(BasicResourcePool.java:44)
    at com.mchange.v2.resourcepool.BasicResourcePool$CheckIdleResourcesTask.run(BasicResourcePool.java:2116)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    ... 5 more

dependencies - maybe hibernate-c3p0 dependecie is enougth? 依赖 - 也许hibernate-c3p0 dependecie是enougth?

<dependency>
    <groupId>com.mchange</groupId>
    <artifactId>c3p0</artifactId>
    <version>0.9.2.1</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>4.3.0.Final</version>
</dependency>

hibernate settings 休眠设置

<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.timeout">3000</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">300</property>

What is the reason for that error and hot to fix it? 这个错误的原因是什么,并且很难修复它? All dependecies related to hibernate-c3p0 are in the classpath. 与hibernate-c3p0相关的所有依赖都在类路径中。

Please refer to the links I added as comments. 请参阅我添加的链接作为评论。 During re-deployment classes are unloaded, if you fail to close Hibernate's sessionFactory then you get these ClassNotFound errors. 在重新部署期间卸载类,如果你无法关闭Hibernate的sessionFactory,那么你会得到这些ClassNotFound错误。 One of the answer suggest that you can add a custom ServletContextListener to handle the contextDestroyed event. 其中一个答案表明您可以添加自定义ServletContextListener来处理contextDestroyed事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM