简体   繁体   English

Tomcat 7上的Spring Stack Web应用程序未停止(需要强制终止)

[英]Spring Stack web-app on Tomcat 7 not stopping (force kill required)

I'm having an issue with tomcat not stopping when requested from time to time and I have to kill the process manually.. I'm using a standard spring stack (JPA, MVC). 我遇到的问题是tomcat有时会在请求时不停止,并且必须手动终止该进程。我正在使用标准的Spring堆栈(JPA,MVC)。 This does not always happen, just about 70% of the time.. I have seen this on both Windows, OSX & Linux platforms... 这并非总是会发生,只是大约70%的时间..我已经在Windows,OSX和Linux平台上都看到了这一点...

Any thoughts why this may be happening.. In the below log, you will see 2 SERVERE log entries but from this question: To prevent a memory leak, the JDBC Driver has been forcibly unregistered seems to say that is not an issue with Tomcat so it leaves the soft reference.. 在下面的日志中,您会看到2个SERVERE日志条目,但是从这个问题出发: 为防止内存泄漏,JDBC驱动程序已被强制注销,这似乎是Tomcat的一个问题,因此,下面的日志中有任何想法。留下软参考。

Any thoughts why this could stop tomcat shutting down? 有什么想法为什么可以停止tomcat关闭?

EDIT : On further Advice & Analysis - it looks like the apache HTTP client is using the DateUtils class, which in turns creates a ThreadLocal instance.. Our code uses the HTTP Client to class an external service... Surely this should be a very common problem if it resides in Apache HTTP Client as using this to call an external HTTP Endpoint isn't uncommon?? 编辑 :在进一步的建议与分析上-看来apache HTTP客户端正在使用DateUtils类,这反过来又创建了一个ThreadLocal实例。我们的代码使用HTTP客户端对外部服务进行分类...当然,这应该是一个非常常见问题(如果它驻留在Apache HTTP Client中),因为使用它来调用外部HTTP端点并不罕见?

Threaddump below log output 日志输出下方的Threaddump

Thanks, 谢谢,

Ian. 伊恩

-2013-01-04 09:18:33,189 DEBUG [http-bio-9999-exec-8] view.InternalResourceView (InternalResourceView.java:236) - Forwarding to resource [/WEB-INF/views/auth/login.jsp] in InternalResourceView 'auth/login'
2013-01-04 09:18:33,191 DEBUG [http-bio-9999-exec-8] servlet.FrameworkServlet (FrameworkServlet.java:913) - Successfully completed request
Jan 04, 2013 9:18:33 AM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jan 04, 2013 9:18:33 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-9999"]
Jan 04, 2013 9:18:33 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 04, 2013 9:18:33 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
2013-01-04 09:18:33,409 INFO  [localhost-startStop-2] support.AbstractApplicationContext (AbstractApplicationContext.java:1025) - Closing WebApplicationContext for namespace 'test-servlet': startup date [Thu Jan 03 17:56:22 GMT 2013]; parent: Root WebApplicationContext
2013-01-04 09:18:33,409 DEBUG [localhost-startStop-2] support.AbstractBeanFactory (AbstractBeanFactory.java:245) - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalScheduledAnnotationProcessor'
2013-01-04 09:18:33,410 DEBUG [localhost-startStop-2] support.AbstractBeanFactory (AbstractBeanFactory.java:245) - Returning cached instance of singleton bean 'lifecycleProcessor'
2013-01-04 09:18:33,410 INFO  [localhost-startStop-2] support.DefaultSingletonBeanRegistry (DefaultSingletonBeanRegistry.java:433) - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@37f293d3: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@2f701b4e
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.AnnotationConfigWebApplicationContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Jan 04, 2013 9:18:33 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [] 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.
Jan 04, 2013 9:18:33 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [] created a ThreadLocal with key of type [org.apache.http.impl.cookie.DateUtils$DateFormatHolder$1] (value [org.apache.http.impl.cookie.DateUtils$DateFormatHolder$1@3f94bcde]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference@3dfbb36e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jan 04, 2013 9:18:33 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-9999"]
Jan 04, 2013 9:18:33 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jan 04, 2013 9:18:33 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-9999"]
Jan 04, 2013 9:18:33 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

--Thread Dump------- -线程转储-------

at org.apache.http.impl.cookie.DateUtils$DateFormatHolder$1.initialValue(DateUtils.java:220) at org.apache.http.impl.cookie.DateUtils$DateFormatHolder$1.initialValue(DateUtils.java:219) at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:160) 在org.apache.http.impl.cookie.DateUtils $ DateFormatHolder $ 1.initialValue(DateUtils.java:219)在org.apache.http.impl.cookie.DateUtils $ DateFormatHolder $ 1.initialValue(DateUtils.java:220) .lang.ThreadLocal.setInitialValue(ThreadLocal.java:160)
at java.lang.ThreadLocal.get(ThreadLocal.java:150) at org.apache.http.impl.cookie.DateUtils$DateFormatHolder.formatFor(DateUtils.java:239) at org.apache.http.impl.cookie.DateUtils.parseDate(DateUtils.java:156) 在org.apache.http.impl.cookie.DateUtils $ DateFormatHolder.formatFor(DateUtils.java:239)在java.lang.ThreadLocal.get(ThreadLocal.java:150)在org.apache.http.impl.cookie.DateUtils .parseDate(DateUtils.java:156)
at org.apache.http.impl.cookie.DateUtils.parseDate(DateUtils.java:114) at org.apache.http.impl.cookie.BasicExpiresHandler.parse(BasicExpiresHandler.java:61) at org.apache.http.impl.cookie.CookieSpecBase.parse(CookieSpecBase.java:93) at org.apache.http.impl.cookie.BestMatchSpec.parse(BestMatchSpec.java:135) at org.apache.http.client.protocol.ResponseProcessCookies.processCookies(ResponseProcessCookies.java:114) at org.apache.http.client.protocol.ResponseProcessCookies.process(ResponseProcessCookies.java:95) at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:116) at org.apache.http.protocol.HttpRequestExecutor.postProcess(HttpRequestExecutor.java:342) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:462) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754) at org.apache.http.impl.client.Abstra 在org.apache.http.impl.cookie.BasicExpiresHandler.parse(BasicExpiresHandler.java:61)在org.apache.http.impl的org.apache.http.impl.cookie.DateUtils.parseDate(DateUtils.java:114) org.apache上的.cookie.CookieSpecBase.parse(CookieSpecBase.java:93).org.apache.http.client.protocol.ResponseProcessCookies.processCookies(ResponseProcessCookies(http.impl.cookie.BestMatchSpec.parse(BestMatchSpec.java:135)) .java:114),位于org.apache.org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:116),位于org.apache.http.client.protocol.ResponseProcessCookies.process(ResponseProcessCookies.java:95)。 org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:462)的http.protocol.HttpRequestExecutor.postProcess(HttpRequestExecutor.java:342)org.apache.http.impl.client.AbstractHttpClient.execute(DefaultRequestDirector.java:462) org.apache.http.impl.client.AbstractHttpClient.java:820)org.apache.http.impl.client.Abstra的AbstractHttpClient.execute(AbstractHttpClient.java:754) ctHttpClient.execute(AbstractHttpClient.java:732) ctHttpClient.execute(AbstractHttpClient.java:732)

It seems that your code uses [org.apache.http.impl.cookie.DateUtils$DateFormatHolder$] at some point. 似乎您的代码在某些时候使用了[org.apache.http.impl.cookie.DateUtils$DateFormatHolder$] This old question tells that HttpClient may be issueing the reference. 这个老问题告诉HttpClient可能正在发布引用。

So you need to look for code, that is using HttpClient - and be sure to cleanup any Thread or HttpClient related resources on contextDestroy. 因此,您需要查找使用HttpClient的代码-并确保清除contextDestroy上与Thread或HttpClient相关的所有资源。

Look at threads in your application, that use HttpClient, you should verify that these threads get stopped properly on shutdown. 查看应用程序中使用HttpClient的线程,您应该验证这些线程在关闭时是否已正确停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM