Play War部署可防止Tomcat停止 [英] Play war deployment prevents Tomcat from stopping

查看:79
本文介绍了Play War部署可防止Tomcat停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Tomcat下的播放应用程序当前遇到一些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通过

使僵尸崩溃

ps -ef

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

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

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方法开始执行.

因此,要确定问题所在,我建立了一个完全全新的播放器2.3.3,仅提供了一个简单的字符串响应.除了play默认系统以外,没有任何actor系统,并且集成了play2war插件以查看问题是由我的代码还是由play本身引起的.问题是一样的.

因此,我正在寻求一些建议,以确保如何关闭这些调度程序和调度程序等,这些调度程序和调度程序是由游戏所产生的,但在关机时却没有被杀死?

我真的很感谢您的帮助!

我还尝试通过删除应用程序库中的oracle驱动程序来尝试 Oracle驱动程序内存泄漏-Tomcat 中提供的解决方案-但没有Tomcat行为的任何变化

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

泄漏错误,Tomcat从未关闭#108

tomcat 6:挂起在关机#161

解决方案

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

Roland Kuhn 所述,可以通过akka将线程设置为守护程序,在后台结束并不能阻止虚拟机关闭.

要执行此操作,只需在application.conf中进行设置:

play.akka.daemonic=on

或者也应该起作用:

akka {
  daemonic=on
}

这样,tomcat将会关闭,而不会出现问题.

I am currently experiencing some onStop issues with my play application under Tomcat. I am using play 2.2.2, sbt 0.13.0, scala 2.10.4 and Tomcat 7 and jdk1.6.

To create a war file I am using the play2war plugin(1.2) with:

Play2WarKeys.servletVersion := "2.5"

So deploying and running the application as well as Tomcat itself is running without any issues. But as soon as I try to stop the server with the default shutdown.sh I get

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.

After that the application and tomcat are down but I still see the tomcat prozess zombieing through

ps -ef

The only possibility to kill it completly is by kill -9 <pid>. So I started searching through the web an stumbled upon similar problems suggesting to perform the .shutdown() and awaitTermination() on the actor system that is used.

So I created a Global object with overriding the onStop method:

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)
  }

}

But it won't solve the issue. I tried to shutdown my own ActorSystem as well as the default play actorsystem through Akka.system but it has no effect.
The onStop method gets execute as I see the Log statements in catalina.out.

So to nail down the problem I set up a completly new play 2.3.3 with just a simple string response. Without a actor system besides the play default one and integrated the play2war plugin to see if the problems are caused by my code or by play itself. And the issue was the same.

So I am locking for some advice how it could be possible to shutdown these scheduler and dispatchers and so on that are spawned by play but not killed on shutdown?

I really would appreciate any help!

Edit:

I also tried the solution provided in Oracle driver memory leak - Tomcat by removing the oracle driver in my application lib - but without any change in the tomcat behaviour

There are also multiple Topics within Play2war Github based on this topic but unfortunatly there are no solutions:

Leak error and Tomcat is never shutdown #108

tomcat 6: hangs on shutdown #161

解决方案

So I found a solution for this problem in this thread: is-there-any-light-weight-actors-in-akka

As described by Roland Kuhn it is possible to set the threads by akka to be daemon, which in the end won`t keep the VM from shutting down.

To do that just set in application.conf:

play.akka.daemonic=on

or which should also work:

akka {
  daemonic=on
}

With that the tomcat will shutdown without problems.

这篇关于Play War部署可防止Tomcat停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆