0

在过去的四天里,我在生产服务器上遇到了一个问题,Tomcat 停止响应,当我尝试通过shutdow.sh 关闭它时,tomcat 进程仍然存在。我将不得不终止该进程并重新启动它。在tomcat崩溃并停止响应之前直接记录下面的堆栈。我做了很多研究,但还没有解决这个问题。

任何帮助表示赞赏

有两个严重的 Web 应用程序错误

Jun 9, 2012 4:50:08 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/beta] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jun 9, 2012 4:50:08 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/beta] appears to have started a thread named [MultiThreadedHttpConnectionManager cleanup] but has failed to stop it. This is very likely to create a memory leak.

和一个 MySQL 错误

INFO: Illegal access: this web application instance has been stopped already.  Could not load com.mysql.jdbc.SQLError.  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:1587)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3358)
    at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1695)
    at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4388)
    at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1368)
    at com.mysql.jdbc.ConnectionImpl.finalize(ConnectionImpl.java:2737)
    at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
    at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
    at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)

下面的全栈

INFO: Destroying Spring FrameworkServlet 'springMvcServlet'
Jun 9, 2012 4:50:08 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Jun 9, 2012 4:50:08 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/beta] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jun 9, 2012 4:50:08 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/beta] appears to have started a thread named [MultiThreadedHttpConnectionManager cleanup] but has failed to stop it. This is very likely to create a memory leak.
Jun 9, 2012 4:50:09 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/bratecp/public_html/beta/WEB-INF/lib/ImageEditor.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Jun 9, 2012 4:50:09 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/bratecp/public_html/beta/WEB-INF/lib/gwt-user.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Jun 9, 2012 4:50:09 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jun 9, 2012 4:50:11 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load com.mysql.jdbc.SQLError.  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:1587)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3358)
    at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1695)
    at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4388)
    at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1368)
    at com.mysql.jdbc.ConnectionImpl.finalize(ConnectionImpl.java:2737)
    at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
    at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
    at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
Jun 9, 2012 4:58:44 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk1.6.0_29/jre/lib/amd64/server:/usr/local/jdk1.6.0_29/jre/lib/amd64:/usr/local/jdk1.6.0_29/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Jun 9, 2012 4:58:44 PM org.apache.catalina.startup.SetAllPropertiesRule begin
WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'compression' to 'on' did not find a matching property.
Jun 9, 2012 4:58:44 PM org.apache.catalina.startup.SetAllPropertiesRule begin
WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'compressionMinSize' to '2048' did not find a matching property.
Jun 9, 2012 4:58:44 PM org.apache.catalina.startup.SetAllPropertiesRule begin
WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'noCompressionUserAgents' to 'gozilla, traviata' did not find a matching property.
Jun 9, 2012 4:58:44 PM org.apache.catalina.startup.SetAllPropertiesRule begin
WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'compressableMimeType' to 'text/xml,text/plain,application/json,application/javascript,text/css' did not find a matching property.
Jun 9, 2012 4:58:44 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '1' did not find a matching property.
Jun 9, 2012 4:58:44 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did not find a matching property.
Jun 9, 2012 4:58:44 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '1' did not find a matching property.
Jun 9, 2012 4:58:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 9, 2012 4:58:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 9, 2012 4:58:45 PM org.apache.catalina.startup.Catalina load
4

1 回答 1

2

至少有两个问题同时出现:

  1. 您正在注册一个 JDBC 驱动程序,该驱动程序是从您的 web 应用程序的 WEB-INF/lib 目录中加载的,并且在您的 web 应用程序关闭时未能取消注册该驱动程序。您可以使用java.sql.DriverManager.deregisterDriver()ServletContextListener.

  2. 您(可能)有一个非守护线程比您的 webapp 寿命更长。确定这里发生了什么的唯一方法是进行线程转储以找出哪个线程仍然处于活动状态(在您运行 shutdown.sh 并等待大约 5 秒以使一切稳定下来之后)以及它可能来自何处。基本上,当您的 webapp 关闭时,您在 webapp 中启动线程的任何地方都需要有一个对称的停止线程。请记住,某些操作会在您没有意识到的情况下启动线程(例如,创建TimerTask、执行某些与 AWT 相关的操作等)。

您可能希望解决这两个问题以提高应用程序服务器的稳定性。

在上面的堆栈跟踪中,它是一个连接终结器,它试图“真正”关闭与数据库的连接。我想知道您是否在 webapp 关闭之前没有正确关闭 Connection 对象(或连接池),因此 Connection 终结器在它们实际实现其目标之后运行(在 ClassLoader 死后)。

于 2012-06-09T17:30:09.093 回答