gpt4 book ai didi

scala - 玩war部署防止Tomcat停止

转载 作者:行者123 更新时间:2023-11-28 21:55:48 25 4
gpt4 key购买 nike

我目前在 Tomcat 下的 Play 应用程序遇到一些 onStop 问题。我正在使用 play 2.2.2、sbt 0.13.0、scala 2.10.4、Tomcat 7 和 jdk1.6。

要创建一个 war 文件,我正在使用 play2war 插件 (1.2):

Play2WarKeys.servletVersion := "2.5"

因此,部署和运行应用程序以及 Tomcat 本身都可以毫无问题地运行。但是,一旦我尝试使用默认的 shutdown.sh 停止服务器,我就会得到

SEVERE: The web application [/WEBSERVICE] appears to have started a thread named [play-scheduler-1] but has failed to stop it. This is very likely to create a memory leak.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WEBSERVICE] appears to have started a thread named [play-akka.actor.default-dispatcher-3] but has failed to stop it. This is very likely to create a memory leak.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WEBSERVICE] appears to have started a thread named [play-akka.actor.default-dispatcher-4] but has failed to stop it. This is very likely to create a memory leak.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/WEBSERVICE] appears to have started a thread named [play-akka.actor.default-dispatcher-5] but has failed to stop it. This is very likely to create a memory leak.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@384e9bea]) and a value of type [scala.concurrent.forkjoin.ForkJoinPool.Submitter] (value [scala.concurrent.forkjoin.ForkJoinPool$Submitter@4e57dc21]) 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.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [scala.concurrent.forkjoin.ThreadLocalRandom$1] (value [scala.concurrent.forkjoin.ThreadLocalRandom$1@4679cf8c]) and a value of type [scala.concurrent.forkjoin.ThreadLocalRandom] (value [scala.concurrent.forkjoin.ThreadLocalRandom@67291479]) 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.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@384e9bea]) and a value of type [scala.concurrent.forkjoin.ForkJoinPool.Submitter] (value [scala.concurrent.forkjoin.ForkJoinPool$Submitter@39ff48d8]) 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.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@384e9bea]) and a value of type [scala.concurrent.forkjoin.ForkJoinPool.Submitter] (value [scala.concurrent.forkjoin.ForkJoinPool$Submitter@27077aa7]) 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.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [akka.actor.ActorCell$$anon$1] (value [akka.actor.ActorCell$$anon$1@5c057df5]) and a value of type [scala.collection.immutable.Nil$] (value [List()]) 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.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@384e9bea]) and a value of type [scala.concurrent.forkjoin.ForkJoinPool.Submitter] (value [scala.concurrent.forkjoin.ForkJoinPool$Submitter@6c908f05]) 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.
Aug 21, 2014 6:15:18 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/WEBSERVICE] created a ThreadLocal with key of type [scala.concurrent.forkjoin.ThreadLocalRandom$1] (value [scala.concurrent.forkjoin.ThreadLocalRandom$1@4679cf8c]) and a value of type [scala.concurrent.forkjoin.ThreadLocalRandom] (value [scala.concurrent.forkjoin.ThreadLocalRandom@69dc8f2]) 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.

在那之后应用程序和 tomcat 都关闭了,但我仍然看到 tomcat prozess zombing through

ps -ef

完全杀死它的唯一可能性是 kill -9 <pid> .所以我开始在网上搜索,偶然发现了类似的问题,建议执行 .shutdown()awaitTermination()在使用的 Actor 系统上。

所以我创建了一个覆盖 onStop 方法的全局对象:

object Global extends GlobalSettings {
val actorSystem = Application.system

override def onStop(app: Application) {
implicit val timeout = Timeout(4 seconds)

Logger.info("Shutting down Actorsystem")

Akka.system.shutdown()
Akka.system.awaitTermination(timeout.duration)
actorSystem.shutdown()
actorSystem.awaitTermination(timeout.duration)
}

}

但这并不能解决问题。我试图通过 Akka.system 关闭我自己的 ActorSystem 以及默认的 Play actorsystem。但是没有效果。
当我在 catalina.out 中看到 Log 语句时,onStop 方法被执行。

因此,为了解决这个问题,我设置了一个全新的 play 2.3.3,只有一个简单的字符串响应。除了 Play 默认之外没有 Actor 系统,并集成了 play2war 插件以查看问题是由我的代码还是由 Play 本身引起的。问题是一样的。

所以我正在锁定一些建议,如何关闭这些调度程序和调度程序等由游戏产生但在关闭时未被杀死的东西?

我真的很感激任何帮助!

编辑:

我也尝试了Oracle driver memory leak - Tomcat中提供的解决方案通过删除我的应用程序库中的 oracle 驱动程序 - 但 tomcat 行为没有任何变化

Play2war Github 中也有多个基于此主题的主题,但不幸的是没有解决方案:

Leak error and Tomcat is never shutdown #108

tomcat 6: hangs on shutdown #161

最佳答案

所以我在这个线程中找到了解决这个问题的方法: is-there-any-light-weight-actors-in-akka

Roland Kuhn 所述可以通过 akka 将线程设置为守护进程,这最终不会阻止 VM 关闭。

要做到这一点,只需在 application.conf 中设置:

play.akka.daemonic=on

或者哪个也应该有效:

akka {
daemonic=on
}

这样,tomcat 将毫无问题地关闭。

关于scala - 玩war部署防止Tomcat停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25443351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com