关闭

Tomcat 启动 异常 java.lang.IllegalStateException: Unable to complete the scan for annotations...

标签: tomcat java.lang.Illtomcat StackOverflowUnable to complete tPossible root causes
3851人阅读 评论(0) 收藏 举报
分类:

最近在使用tomcat 部署应用是遇到异常如下:


Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/xxxx] 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.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1EncodableVector]
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2188)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2135)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2010)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1976)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1961)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1319)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
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:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more

分析原因:tomcat 启动扫描注解时抛出异常 StackOverflowError,扫描具体类为:

org.bouncycastle.asn1.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1EncodableVector

从以下方面检查错误:

1. 栈内存不足,修改tomcat启动参数,增加栈内存, 如:-Xss100m

2. 在你的应用中告诉tomcat不要扫描annotations, 修改web.xml 如下:

<web-app id="WebApp_ID" version="2.4" metadata-complete="true"
        xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


3. 限制tomcat扫描jar 文件,参考:http://tomcat.apache.org/tomcat-7.0-doc/config/jar-scanner.html

4. 另外, 你可以创建一个war包,其中在WEB-INF\lib中包含第三方依赖的jar, 当启动tomcat时,如果发现错误信息类似如下:

Unable to complete the scan for annotations for web application [/xxxx] 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.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1EncodableVector]

这个可能是第三方api的一个bug.可以到其官网下载最新版本看看是否修复。

1
1

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:11674次
    • 积分:207
    • 等级:
    • 排名:千里之外
    • 原创:7篇
    • 转载:1篇
    • 译文:2篇
    • 评论:1条
    文章分类