Tomcat启动报StackOverflowError

Posted 水木竹水

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tomcat启动报StackOverflowError相关的知识,希望对你有一定的参考价值。

近期工程部署到Tomcat时,出现以下异常:

16-May-2018 09:35:25.590 严重 [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/test]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1853)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/test] due to a StackOverflowError. 
Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was
[org.bouncycastle.asn1.ASN1Boolean->org.bouncycastle.asn1.DERBoolean->org.bouncycastle.asn1.ASN1Boolean] at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2108) at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2054) at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1999) at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1969) at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1923) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1166) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ... 10 more 16-May-2018 09:35:25.606 严重 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application
archive E:\nccode\tomcat\webapps\test.war java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[
/test]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1853) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

 

红色部分是主要问题,经查询,其中 [org.bouncycastle.asn1.ASN1Boolean->org.bouncycastle.asn1.DERBoolean->org.bouncycastle.asn1.ASN1Boolean ] 形成了环状继承关系,导致出现StackOverflowError,主要原因是Maven依赖引入了2个包,分别具有不同的继承关系,去除其中一个不需要的依赖即可

解决方法:

(1)在工程中找到ASN1Boolean和DERBoolean,发现有2个依赖包含着2个类,并且继承关系相反;

(2)2个依赖中有一个是间接依赖,将这个依赖排除在外即可,如下:

<dependency>
            <groupId> </groupId>
            <artifactId> </artifactId>
            <version> </version>
            <exclusions>
                <exclusion>
                    <groupId> </groupId>
                    <artifactId> </artifactId>
                </exclusion>
            </exclusions>
        </dependency>

 





以上是关于Tomcat启动报StackOverflowError的主要内容,如果未能解决你的问题,请参考以下文章

tomcat 启动报错日志查看

java服务tomcat启动报错

tomcat启动报错,求高手指点

tomcat启动报错了,求教高手解答

Tomcat 启动,报如下错误?

tomcat启动报错