【发布时间】:2014-08-22 09:07:07
【问题描述】:
我目前在 Tomcat 下使用我的 play 应用程序时遇到了一些 onStop 问题。 我正在使用 play 2.2.2、sbt 0.13.0、scala 2.10.4 和 Tomcat 7 和 jdk1.6。
要创建一个战争文件,我使用 play2war 插件(1.2):
Play2WarKeys.servletVersion := "2.5"
所以部署和运行应用程序以及 Tomcat 本身运行没有任何问题。但是,一旦我尝试使用默认的 shutdown.sh 停止服务器,我就会得到 p>
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僵尸通过
ps -ef
完全杀死它的唯一可能是kill -9 <pid>。
所以我开始在网上搜索,偶然发现了类似的问题,建议在使用的演员系统上执行.shutdown() 和awaitTermination()。
所以我创建了一个覆盖 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 以及默认的播放 actorsystem,但它没有任何效果。
当我在 catalina.out 中看到 Log 语句时,onStop 方法得到执行。
所以为了解决这个问题,我只用一个简单的字符串响应设置了一个全新的播放 2.3.3。除了播放默认的演员系统外,没有演员系统,并集成了 play2war 插件,以查看问题是由我的代码还是由 play 本身引起的。问题是一样的。
所以我正在锁定一些建议,如何关闭这些调度程序和调度程序等等,这些调度程序和调度程序等是由游戏产生但在关闭时不会被杀死的?
我真的很感激任何帮助!
编辑:
我还尝试了Oracle driver memory leak - Tomcat 中提供的解决方案,方法是删除我的应用程序库中的 oracle 驱动程序 - 但 tomcat 行为没有任何变化
Play2war Github 中也有多个基于此主题的主题,但遗憾的是没有解决方案:
【问题讨论】:
-
不是答案,但根据我的经验,很难确定 tomcat 真的会停止。我的建议是将 tomcat 作为服务运行。除了其他优点外,它会始终确保在关闭服务时停止 tomcat。
-
谢谢。不幸的是,我不知道
t have the possibility to run it as a service. Besides that I dont 真正理解的意思是:“很难确定 tomcat 真的停止了”。因为要么进程结束,端口不再被占用?
标签: scala tomcat playframework akka playframework-2.2