java 可能的根本原因包括 -Xss 设置过低和非法循环继承依赖

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14910757/
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 17:49:36  来源:igfitidea点击:

Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies

javaspringtomcat

提问by Selvam Rajendran

My app is quit big and using many jars and tools. Platform - windows 2008 server, Spring , hibernate, Quarts, mysql, tomcat-7.35

我的应用程序很大并且使用了许多 jars 和工具。平台 - windows 2008 服务器、Spring、hibernate、Quarts、mysql、tomcat-7.35

When I deploy and start the server first time working perfectly, but If I restart I am getting the below err

当我第一次部署并启动服务器时,服务器运行良好,但如果我重新启动,我会收到以下错误

    SEVERE: ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestProject]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    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.IllegalStateException: Unable to complete the scan for annotations for web application [/TestProject]. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2109)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1981)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1947)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1932)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1326)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more
    Caused by: java.lang.StackOverflowError
    at java.util.HashSet.<init>(HashSet.java:103)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2252)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)

    Feb 16, 2013 12:16:10 PM org.apache.catalina.startup.HostConfig deployDirectory
    SEVERE: Error deploying web application directory C:\apache-tomcat-7.0.35\webapps\TestProject
    java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[TestProject]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    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)

回答by ams

The stack trace says that tomcat is running out of stack space on the thread that is scanning your application looking for java based servlet configurations. There are three ways you can solve this problem.

堆栈跟踪表明 tomcat 正在扫描您的应用程序以查找基于 Java 的 servlet 配置的线程上的堆栈空间不足。您可以通过三种方法解决此问题。

Update 1

更新 1

you need to pass -Xss4m to your jvm to set the stack size, -Xss10m would set it to 10mb.

您需要将 -Xss4m 传递给您的 jvm 以设置堆栈大小,-Xss10m 会将其设置为 10mb。

I am using Hibernate and Spring in my application too with annotations, the scanning that tomcat does is to look for Servlet 3.0 annotations so you can still restrict things while using hibernate and spring annotations, since hibernate and spring annoations are scanned for by spring and hibernate.

我在我的应用程序中也使用带有注释的 Hibernate 和 Spring,tomcat 所做的扫描是查找 Servlet 3.0 注释,因此您仍然可以在使用 hibernate 和 spring 注释时进行限制,因为 spring 和 hibernate 会扫描 hibernate 和 spring 注释.

If you are running tomcat as a windows service you will need, to pass the arguments via procrun since that is the executable that is launching the jvm. The docs for procrun are at http://commons.apache.org/daemon/procrun.html. tomcat7.exe is really procrun.exe renamed, which means that all your jvm options are written to the registery under

如果您将 tomcat 作为 Windows 服务运行,则需要通过 procrun 传递参数,因为这是启动 jvm 的可执行文件。procrun 的文档位于http://commons.apache.org/daemon/procrun.html。tomcat7.exe真的是procrun.exe改名了,也就是说你所有的jvm选项都写到了registery下

The basic Service definitions are maintained under the registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\

Additional parameters are stored in the registry at:

HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\ProcRun 2.0\\Parameters

On 64-bit Windows procrun always uses 32-bit registry view for storing the configuration. This means that parameters will be stored inside:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\ProcRun 2.0\

基本服务定义在注册表项下维护:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\

其他参数存储在注册表中:

HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\ProcRun 2.0\\Parameters

在 64 位 Windows 上,procrun 始终使用 32 位注册表视图来存储配置。这意味着参数将存储在:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\ProcRun 2.0\

Update 2

更新 2

Tomcat has been tweaking how the scanner works between point releases. try rolling forward through the versions 7.25,7.26 ... etc to find the version at which it breaks, the go through the release notes for that version to see if they changed how the scanner works.

Tomcat 一直在调整扫描器在不同版本之间的工作方式。尝试向前滚动版本 7.25、7.26 ... 等以查找其中断的版本,查看该版本的发行说明以查看它们是否更改了扫描仪的工作方式。

Another thing you can try doing, is to create another war file which has all the third party jars in your WEB-INF\lib but not your code. See if you get that error if you start up, and if you do then should file a bug report with tomcat and make available to them your sample project that replicates the problem, on github or some other free code hosting system. I am sure if there is a bug they will fix it.

您可以尝试做的另一件事是创建另一个 war 文件,其中包含 WEB-INF\lib 中的所有第三方 jar,但不包含您的代码。看看你是否在启动时遇到那个错误,如果你这样做了,那么应该用 tomcat 提交一个错误报告,并在 github 或其他一些免费的代码托管系统上向他们提供复制问题的示例项目。我相信如果有错误,他们会修复它。

回答by enkor

To fix this for TC Server 2.9, running Tomcat 7.0.39 I restricted the jars to skip during startup for the context config using:

为了在运行 Tomcat 7.0.39 的 TC Server 2.9 上解决这个问题,我使用以下方法限制了 jars 在启动期间跳过上下文配置:

org.apache.catalina.startup.ContextConfig.jarsToSkip=*.jar

in catalina.properties.

在 catalina.properties 中。

回答by Mahesh S

In My case iTextpdf JAR(5.06 version) causing problem as it had dependancy on org.bouncyCastle.*.jarand it was creating cyclic dependancy.

在我的情况下,iTextpdf JAR(5.06 版本)导致问题,因为它具有依赖关系org.bouncyCastle.*.jar并且它正在创建循环依赖关系。

After updating it to 5.5.6version, worked perfectly. If you are adding maven dependancy , clean and update maven project.

更新到5.5.6版本后,完美运行。如果您要添加 maven 依赖项,请清理并更新 maven 项目。

<dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.5.6</version>
</dependency>

回答by jim.cantor

I'm not running Tomcat as a Windows service, so to pass -Xss10mthrough, I edited catalina.bat, towards the bottom:

我没有将 Tomcat 作为 Windows 服务运行,所以为了-Xss10m通过,我在底部编辑了 catalina.bat:

:doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -Xss10m -classpath "%CLASSPATH%" -

Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
goto end