Tomcat 7 随机崩溃并出现 ClassNotFoundException

Tomcat 7 randomly crashes with ClassNotFoundException

我在 Tomcat7 中有一个 Scala 应用程序 运行,最近由于标准 类 的 ClassNotFoundException 错误开始随机崩溃,例如 scala.collection.immutable.ListSet 即使服务器运行 一段时间以来一直很好。错误开始变得越来越频繁,现在我们在某些服务器上每天都会遇到几次崩溃

这是我们在 catalina.out 日志文件中获取的崩溃日志示例。

Dec 25, 2018 8:50:47 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 25, 2018 8:50:47 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6938 ms
Uncaught error from thread [TPDispatcher-akka.actor.default-dispatcher-4] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[TPDispatcher]
java.lang.NoClassDefFoundError: scala/collection/immutable/ListSet$
        at scala.collection.immutable.HashSet$HashSet1.updated0(HashSet.scala:145)
        at scala.collection.immutable.HashSet$HashTrieSet.updated0(HashSet.scala:227)
        at scala.collection.immutable.HashSet$HashTrieSet.updated0(HashSet.scala:227)
        at scala.collection.immutable.HashSet$HashTrieSet.updated0(HashSet.scala:227)
        at scala.collection.immutable.HashSet$HashTrieSet.updated0(HashSet.scala:227)
        at scala.collection.immutable.HashSet.$plus(HashSet.scala:56)
        at scala.collection.immutable.HashSet.$plus(HashSet.scala:33)
        at scala.collection.mutable.SetBuilder.$plus$eq(SetBuilder.scala:24)
        at scala.collection.mutable.SetBuilder.$plus$eq(SetBuilder.scala:22)
        at scala.collection.TraversableLike$$anonfun$map.apply(TraversableLike.scala:244)
        at scala.collection.TraversableLike$$anonfun$map.apply(TraversableLike.scala:244)
        at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:153)
        at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:306)
        at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:306)
        at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:306)
        at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:306)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
        at scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)
        at scala.collection.SetLike$class.map(SetLike.scala:93)
        at scala.collection.AbstractSet.map(Set.scala:47)
        at com.mycompany.lib.actors.BadgeUpdater.updateBadge(BadgeUpdater.scala:23)
        at com.mycompany.lib.actors.BadgeUpdater$$anonfun$receive.applyOrElse(BadgeUpdater.scala:15)
        at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
        at com.twinpush.tp_dispatcher.lib.actors.BadgeUpdater.aroundReceive(BadgeUpdater.scala:11)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
        at akka.actor.ActorCell.invoke(ActorCell.scala:487)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
        at akka.dispatch.Mailbox.run(Mailbox.scala:220)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.ClassNotFoundException: scala.collection.immutable.ListSet$
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1859)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1702)
        ... 33 more
Dec 26, 2018 2:15:31 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Dec 26, 2018 2:15:31 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina

我试过多次重新编译,但都没有成功。我不知道在已经 运行 的服务器上可能会导致 ClassNotFoundException 的原因,因此非常感谢任何提示。


环境信息:

Scala version:  2.10.4
Server version: Apache Tomcat/7.0.68 (Ubuntu)
Server built:   Oct 30 2018 12:54:52 UTC
Server number:  7.0.68.0
OS Name:        Linux
OS Version:     4.4.0-141-generic
Architecture:   amd64
JVM Version:    1.8.0_191-8u191-b12-0ubuntu0.16.04.1-b12
JVM Vendor:     Oracle Corporation

原来我有一个库正在泄漏​​文件描述符,并且在某些时候 JVM 无法打开 class 文件(这甚至可能吗?)。升级库修复了漏洞,JVM 停止崩溃。