可能的根本原因包括-Xss的设置太低以及非法循环继承依赖性

时间:2013-02-16 13:19:19

标签: java spring tomcat

我的应用程序退出了大量并使用了许多罐子和工具。 平台 - windows 2008服务器,Spring,hibernate,Quarts,mysql,tomcat-7.35

当我第一次完全部署并启动服务器时, 但如果我重新启动,我会得到以下错误

    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)

4 个答案:

答案 0 :(得分:11)

堆栈跟踪说明tomcat正在扫描你的应用程序寻找基于java的servlet配置的线程上的堆栈空间不足。有三种方法可以解决这个问题。

更新1

你需要将-Xss4m传递给你的jvm来设置堆栈大小,-Xss10m会将它设置为10mb。

我在我的应用程序中也使用Hibernate和Spring注释,tomcat执行的扫描是查找Servlet 3.0注释,因此在使用hibernate和spring注释时仍然可以限制事物,因为hibernate和spring annoations是由扫描的春天和冬眠。

如果您正在运行tomcat作为Windows服务,则需要通过procrun传递参数,因为这是启动jvm的可执行文件。 procrun的文档位于http://commons.apache.org/daemon/procrun.html。 tomcat7.exe真的是procrun.exe重命名,这意味着你所有的jvm选项都被写入了注册表

  

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

     

HKEY_LOCAL_MACHINE \ SYSTEM \ CURRENTCONTROLSET \服务\

     

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

     

HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation \ ProcRun   2.0 \\参数

     

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

中      

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

更新2

Tomcat一直在调整扫描仪在点发布之间的工作方式。尝试翻阅版本7.25,7.26 ...等以找到它破坏的版本,浏览该版本的发行说明,看看它们是否改变了扫描仪的工作方式。

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

答案 1 :(得分:9)

要为TC Server 2.9修复此问题,运行Tomcat 7.0.39我使用以下命令限制jars在启动期间跳过上下文配置:

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

在catalina.properties中。

答案 2 :(得分:1)

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

将其更新为5.5.6版本后,效果非常好。 如果要添加maven依赖性,请清理并更新maven项目。

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

答案 3 :(得分:0)

我没有将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