java 在 tomcat 7 上部署战争时的无限循环

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12263684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:14:10  来源:igfitidea点击:

Infinite loop when deploying a war on tomcat 7

javatomcatdeploymentwarwebarchive

提问by user1646171

I try to deploy a war into Tomcat 7.0.29. I'm having the following log stack :

我尝试将War部署到 Tomcat 7.0.29 中。我有以下日志堆栈:

GRAVE: Error waiting for multi-thread deployment of context descriptors to complete
java.util.concurrent.ExecutionException: java.lang.StackOverflowError
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:574)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1413)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:313)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:346)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1140)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.StackOverflowError
    at java.util.HashSet.<init>(HashSet.java:86)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2208)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2227)

(Many stack frames ommited...)

(省略了许多堆栈帧...)

Does anybody face the same problem ?

有人面临同样的问题吗?

回答by Joe

This is reported upstream as issue #53871in Tomcat. The problem appears to be with annotation scanning, and Tomcat 7.0.38 includes a clearer error message.

这在上游报告为Tomcat 中的问题#53871。问题似乎与注释扫描有关,Tomcat 7.0.38 包含更清晰的错误消息。

From the bug report:

从错误报告:

Due to dependency management problems I deployed a WAR file containing two JAR files containing different versions of a library, where version 1 contained a class A which inherited from B and another version 2 which contained a class B inheriting from A. The classes were loaded in such an order that A and B cyclically inherited from each other which leads to a stack overflow in populateSCIsForCacheEntry because it does not detect cycles in the inheritance tree.

由于依赖管理问题,我部署了一个 WAR 文件,其中包含两个包含不同版本库的 JAR 文件,其中版本 1 包含从 B 继承的类 A 和另一个包含从 A 继承的类 B 的版本 2。这些类被加载到A 和 B 循环继承的这种顺序会导致 populateSCIsForCacheEntry 中的堆栈溢出,因为它没有检测到继承树中的循环。

This was exactly the problem in my case: an old version of dom4jbundled an incompatible version of jaxen. The new error diagnostic in 7.0.38 showed exactly which classes formed a loop and I fixed it by upgrading those dependencies.

这正是我的问题所在:旧版本dom4j捆绑了不兼容的jaxen. 7.0.38 中的新错误诊断准确显示了哪些类形成了循环,我通过升级这些依赖项来修复它。

回答by spierobi

I'm also encountering this issue in Tomcat 7.0.29and Tomcat 7.0.30. However with Tomcat 7.0.28everything works fine, so I suspect it's Tomcat issue, that was recently introduced.

我也在 Tomcat 7.0 中遇到了这个问题。29和 Tomcat 7.0。30. 但是使用 Tomcat 7.0. 28一切正常,所以我怀疑这是最近引入的 Tomcat 问题。

The error encountered in 7.0.29and 7.0.30, when starting Tomcat and deploying a war file:

7.0 中遇到的错误。29和 7.0。30、启动Tomcat并部署war文件时:

14:01:06,380 ERROR [HostConfig:576] Error waiting for multi-thread deployment of context descriptors to complete java.util.concurrent.ExecutionException: java.lang.StackOverflowError
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:574)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1413)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:313)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:346)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1140)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.StackOverflowError
    at java.util.HashSet.<init>(HashSet.java:103)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2243)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2260)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2260)

回答by Pascal

A workaround : I changed the name of the WAR(no finalName in pom.xml and changed the artifact version) and it worked .... why? I don't know till now!

解决方法:我更改了WAR的名称(在 pom.xml 中没有 finalName 并更改了工件版本)并且它有效......为什么?到现在都不知道!

A real and a genuine solution? Definitely a new TomcatRelease . . .

一个真正的和真正的解决方案?绝对是一个新的Tomcat版本。. .

回答by Elijah Saounkine

For me this behavior reproduced in IntelliJ Idea when I set the Application Context to the same name as the the Maven atrifactId in the .pom file. E.g. my artifactId is 'test', then I set the Application Context (Edit configuration -> Tomcat Server -> Deployment, select the exploded artifact) to '/test'. As soon as I changed the Application Context, everything worked.

对我来说,当我将应用程序上下文设置为与 .pom 文件中的 Maven atrifactId 相同的名称时,这种行为在 IntelliJ Idea 中重现。例如,我的 artifactId 是“test”,然后我将应用程序上下文(编辑配置 -> Tomcat 服务器 -> 部署,选择分解的工件)设置为“/test”。一旦我更改了应用程序上下文,一切都正常了。

回答by Kishor Prakash

Use a lower version of Tomcat. There are problems with the version of Tomcatyou are using.

使用较低版本的Tomcat。您使用的Tomcat版本有问题。

回答by ronaldhan

I had the same problem. I think it was caused by Tomcat 7, so when I changed to Tomcat 6.0.35, the problem resolved itself like a charm.

我有同样的问题。我认为是由Tomcat 7引起的,所以当我更改为Tomcat 6.0.35 时,问题就像一个魅力一样自行解决。