hilljordan
hilljordan
采纳率50%
2016-04-05 03:22 阅读 5.2k

hibernate + c3p0连接池 出现以下错误,求解答!

5

05-Apr-2016 10:36:43.186 INFO [C3P0PooledConnectionPoolManager[identityToken->2sbh7t9f1rc58zmz5ikx9|52feca18]-AdminTaskTimer] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1354)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1340)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1205)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
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->2sbh7t9f1rc58zmz5ikx9|52feca18]-AdminTaskTimer" java.lang.IllegalStateException: Can't overwrite cause with java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at java.lang.Throwable.initCause(Throwable.java:457)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1343)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1205)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
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
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1342)
... 7 more
1、此错误会不定时出现。
2、hibernate版本是4.3.5,Struts2版本是2.3.24.1;并没有使用spring...
3、出现此错误时,CRUD功能正常!
在网上找了两天资料,没找到正确的解决方法,求大神解答!谢谢

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • hilljordan hilljordan 2016-04-05 03:27

    直接到hibernate的lib库上引入关于c3p0的三个包:
    1、c3p0-0.9.2.1.jar
    2、hibernate-c3p0-4.3.5.Final.jar
    3、mchange-commons-java-0.2.3.4.jar

    点赞 1 评论 复制链接分享
  • hilljordan hilljordan 2016-04-05 03:24
        c3p0连接池的配置如下:
                <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.timeout">120</property>
        <property name="automaticTestTable">Test</property>
        <property name="hibernate.c3p0.max_statements">100</property>
        <property name="hibernate.c3p0.idle_test_period">120</property>
        <property name="hibernate.c3p0.acquire_increment">1</property>
        <property name="c3p0.testConnectionOnCheckout">true</property>
        <property name="c3p0.idleConnectionTestPeriod">18000</property>
        <property name="c3p0.maxIdleTime">25000</property>
        <property name="c3p0.idle_test_period">120</property>
    
    点赞 评论 复制链接分享
  • Royal_lr Royal_lr 2016-04-05 06:50

    貌似是少了jar包的问题,,重新导入一下jar试试

    点赞 评论 复制链接分享

相关推荐