困扰老子好久啊!!tomcat的两个错…

来源:互联网 发布:后盾网php视频教程 编辑:程序博客网 时间:2024/06/10 19:12
转:http://blog.csdn.net/snoopy93/article/details/6800660
今天tomcat 6遇到两个错误提示:
1.
严重: A web application registered the JBDC driver[com.mysql.jdbc.Driver] but failed to unregister it when the webapplication was stopped. To prevent a memory leak, the JDBC Driverhas been forcibly unregistered.


原因:重复加载了jar包。
解决方法:原来我在tomcat的lib文件夹放入了com.mysql.jdbc.Driver的jar包,而又在项目里面重复添加了,导致了上面的提示。删掉其中一个解决问题。


2.The web application [/snoopy] created a ThreadLocal with key oftype [com.opensymphony.xwork2.inject.ContainerImpl$10] (value[com.opensymphony.xwork2.inject.ContainerImpl$10@ea85b4]) and avalue of type [java.lang.Object[]] (value[[Ljava.lang.Object;@efeff8]) but failed to remove it when the webapplication was stopped. Threads are going to be renewed over timeto try and avoid a probable memory leak.


原因:tomcat 6.026之后的版本加入了 memory leak detectionfeature(内存泄露检查)看如下原文:
There is a memory leak detection feature introduced in Tomcat6.0.26 that attempts to log objects that have failed to beunregistered by webapps it hosts when they are stopped, and wereforcibly unregistered by Tomcat. As Tomcat is forcibly removingthese objects, it is not a serious concern that these log messagesoccur.


解决方法:在tomcat 的server.xml文件中将注释掉即可
PS:这是一个治标不治本的方法。
 
***********************************

解决”To prevent a memory leak, the JDBC Driver has been forciblyunregistered“

  • 博客分类:
  • 项目总结
 

     

  在开发过程中,添加完UrlWriter之后,部署到了服务器环境,发生了如下错误

    

Java代码 复制代码 收藏代码困扰老子好久啊!!tomcat的两个错误提示
  1. To prevent memory leak, the JDBC Driver has been forcibly unregistered.    
To prevent a memory leak, the JDBC Driver has been forcibly unregistered.  

   

    原来Tomcat6会起一个线程检测是否有内存泄露

写道
Ignore those warnings. Tomcat is doing itsjob right. The actual bug is in someone else's code (the JDBCdriver in question), not in yours. Be happy that Tomcat did its jobproperly and wait until the JDBC driver vendor get it fixed so thatyou can upgrade the driver.

Downgrade to Tomcat 6.0.23 or older so that you will not bebothered with those warnings. But it will silently keep leakingmemory. Not sure if that's good to know after all. Those kind ofmemory leaks are one of the major causes behind OutOfMemoryErrorissues during Tomcat hotdeployments.

Move the JDBC driver to Tomcat's /lib folder and have a connectionpooled datasource to manage the driver. Note that Tomcat's builtinDBCP does not deregister drivers properly on close. See also bugDBCP-322. The DBCP project is however currently stalling. Iwouldn't expect quick updates. You would rather like to replaceDBCP by another connection pool which is doing its job better thenDBCP. For example BoneCP or Tomcat JDBC Pool maybe?

 

   解决办法有两个

    1)将UrlWirter的Filter从web.xml中去掉或者重写destory方法

    2)将Mysql的驱动包复制一份到Tomcat的Lib目录下