环境: 服务器:Jboss 4.2.3.GA
我们正在使用c3p0 0.9.1.2进行连接池。
每当我们热部署时,Jboss AS中的war文件都会遇到来自c3p0的内存泄漏。 它最终导致“java.lang.OutOfMemoryError:PermGen space”错误,我们被迫重启我们的应用服务器。
有没有人遇到过这个问题?这个问题有解决办法吗?
Stacktrace如下:
14:50:16,097 INFO [WebappClassLoader] Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask. 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:1244)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
14:50:22,328 ERROR [STDERR] Exception in thread "Timer-5"
14:50:22,329 ERROR [STDERR] java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$1DestroyResourceTask
14:50:22,329 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
14:50:22,329 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
14:50:22,329 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
14:50:22,329 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
14:50:22,329 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
14:50:22,329 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
14:50:22,329 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512)
14:50:22,329 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)
14:50:22,329 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask
14:50:22,329 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
14:50:22,329 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
14:50:22,329 ERROR [STDERR] ... 8 more
14:50:23,081 ERROR [STDERR] Exception in thread "Timer-6"
14:50:23,082 ERROR [STDERR] java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$1DestroyResourceTask
14:50:23,082 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
14:50:23,082 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
14:50:23,082 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
14:50:23,082 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
14:50:23,082 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
14:50:23,082 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
14:50:23,082 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512)
14:50:23,083 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)
14:51:59,105 INFO [WebappClassLoader] Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask. 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:1244)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
^[[1;2C14:56:03,597 ERROR [STDERR] Exception in thread "Timer-11"
14:56:03,598 ERROR [STDERR] java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$1DestroyResourceTask
14:56:03,598 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
14:56:03,598 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
14:56:03,598 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
14:56:03,598 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
14:56:03,598 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
14:56:03,598 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
Listening for transport dt_socket at address: 8787
14:56:03,598 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512)
14:56:03,598 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)
14:56:03,598 ERROR [STDERR] Exception in thread "Timer-10"
14:56:03,607 ERROR [STDERR] java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$1DestroyResourceTask
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
14:56:03,607 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512)
14:56:03,607 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)
14:56:03,607 ERROR [STDERR] Exception in thread "Timer-9"
14:56:03,607 ERROR [STDERR] java.lang.NoClassDefFoundError: com/mchange/v2/resourcepool/BasicResourcePool$1DestroyResourceTask
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:980)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1406)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1378)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1462)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:32)
14:56:03,607 ERROR [STDERR] at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:1937)
14:56:03,607 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512)
14:56:03,607 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)
14:56:03,607 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask
14:56:03,607 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
14:56:03,607 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
14:56:03,607 ERROR [STDERR] ... 8 more
答案 0 :(得分:5)
每当我们在Jboss AS中热部署war文件时,都会遇到来自c3p0的内存泄漏。
如果在JBoss 4.2(或任何其他版本的JBoss)中进行热部署,最终会泄漏PermGen池中的内存,服务器将需要重新启动。没有我知道的解决方法,它与c3p0无关。
在开发过程中,这只是一个小麻烦。在制作中,你根本不应该这样做。