为防止内存泄漏,JDBC驱动程序已被强制取消注册 [英] To prevent a memory leak, the JDBC Driver has been forcibly unregistered

查看:4835
本文介绍了为防止内存泄漏,JDBC驱动程序已被强制取消注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行我的网络应用程序时收到此消息。它运行正常但我在关机期间收到此消息。

I am getting this message when I run my web application. It runs fine but I get this message during shutdown.


SEVERE:Web应用程序注册了JBDC驱动程序[oracle.jdbc.driver.OracleDriver ]但是在Web应用程序停止时无法注销它。为防止内存泄漏,JDBC驱动程序已被强制取消注册。

SEVERE: A web application registered the JBDC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

任何帮助表示赞赏。

推荐答案

从版本6.0.24开始,Tomcat附带一个内存泄漏检测功能,当webapp的 / WEB-INF / lib 中存在与JDBC 4.0兼容的驱动程序时,该功能又会导致此类警告消息自动使用 <$在webapp启动期间注册 c $ c> ServiceLoader API ,但没有自动 - 取消注册本身duri ng webapp的关机。这条消息完全是非正式的,Tomcat已经相应地采取了内存泄漏预防措施。

Since version 6.0.24, Tomcat ships with a memory leak detection feature, which in turn can lead to this kind of warning messages when there's a JDBC 4.0 compatible driver in the webapp's /WEB-INF/lib which auto-registers itself during webapp's startup using the ServiceLoader API, but which did not auto-deregister itself during webapp's shutdown. This message is purely informal, Tomcat has already taken the memory leak prevention action accordingly.

你能做什么?


  1. 忽略这些警告。 Tomcat正在做正确的工作。实际的错误是在别人的代码(有问题的JDBC驱动程序)中,而不是在你的代码中。很高兴Tomcat正确地完成了它的工作并等到JDBC驱动程序供应商修复它以便你可以升级驱动程序。另一方面,您不应该在webapp的 / WEB-INF / lib 中删除​​JDBC驱动程序,而只能在服务器的 / lib <中删除/ code>。如果你仍然将它保存在webapp的 / WEB-INF / lib 中,那么你应该使用 ServletContextListener 。

  1. Ignore those warnings. Tomcat is doing its job right. The actual bug is in someone else's code (the JDBC driver in question), not in yours. Be happy that Tomcat did its job properly and wait until the JDBC driver vendor get it fixed so that you can upgrade the driver. On the other hand, you aren't supposed to drop a JDBC driver in webapp's /WEB-INF/lib, but only in server's /lib. If you still keep it in webapp's /WEB-INF/lib, then you should manually register and deregister it using a ServletContextListener.

降级到Tomcat 6.0.23或更早版本,这样您就不会被这些警告所困扰。但它会默默地保持泄露记忆。毕竟不确定这是否有用。这些内存泄漏是 OutOfMemoryError 。

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

将JDBC驱动程序移动到Tomcat的 / lib 文件夹并有一个连接池数据源来管理驱动程序。请注意,Tomcat的内置DBCP在关闭时不会正确注销驱动程序。另见作为WONTFIX关闭的 DBCP-322 错误。您更愿意将DBCP替换为另一个连接池,它比DBCP更好地完成其工作。例如 HikariCP BoneCP ,或者可能是 Tomcat JDBC Pool

Move the JDBC driver to Tomcat's /lib folder and have a connection pooled datasource to manage the driver. Note that Tomcat's builtin DBCP does not deregister drivers properly on close. See also bug DBCP-322 which is closed as WONTFIX. You would rather like to replace DBCP by another connection pool which is doing its job better then DBCP. For example HikariCP, BoneCP, or perhaps Tomcat JDBC Pool.

这篇关于为防止内存泄漏,JDBC驱动程序已被强制取消注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆