Tomcat 警告:与线程池 [http-apr-8080] 关联的执行器尚未完全关闭

Tomcat warning: The executor associated with thread pool [http-apr-8080] has not fully shutdown

我是 运行 在 linux 服务器上使用 tomcat8 和 jdk1.8 的 Web 应用程序。

当我关闭 tomcat 时,我收到以下警告消息:

WARNING [main] org.apache.tomcat.util.net.AbstractEndpoint.shutdownExecutor The executor associated with thread pool [http-apr-8080] has not fully shutdown. Some application threads may still be running

注意:我仅在关闭 tomcat 时收到此警告,而不是在取消部署我的应用程序时收到此警告。

我怎样才能 "fix" 这个警告,这样消息就不会出现了。 当应用程序 运行 时,我使用 Jstack 进行了线程转储,我看到了几个 http-apr-8080-exec 线程。

谢谢

我们必须在关闭 tomcat 之前停止任何应用程序,因为 servlet 可能会在关闭过程中为请求提供服务。

参考: https://www.safaribooksonline.com/library/view/tomcat-the-definitive/0596003188/ch01s02.html

请检查部分- 正在重新启动 Tomcat 它说 "The Java Servlet Specification also dictates that, on shutdowns, servlet containers must wait for each servlet to finish serving all requests that are in progress or wait a container-specific timeout duration before taking servlets out of service. For Tomcat 4, that timeout duration is a maximum of a half-second per servlet. When a servlet misbehaves and takes too long to finish serving requests, it's up to Tomcat to figure out that the servlet has taken too long and to forcibly take it out of service so that Tomcat can shut down. This processing takes time, though, and slows Tomcat's own shutdown processing."

最佳实践: 当您从 tomcat 停止应用程序时,servlet 停止服务。所以你不会遇到这个问题。

请按照先停止应用程序的流程,关闭tomcat服务器。

此错误是由于关闭 tomcat 而实例仍在 "attached" 到弹性负载均衡器的结果。 ELB 有一个名为 Connection Draining 的特性,默认情况下,它被设置为 300 秒。 您可以在关闭 tomcat 之前禁用连接耗尽或仅从 ELB 中删除实例,以免收到警告消息。