乐趣区

关于tomcat:问题记录TomcatTomcat启动报错Possiblefor-Xss-and-illegal

Tomcat 启动报错:Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies

错误代码如下:

Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [] 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:2139)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2083)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2029)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1999)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1952)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1156)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:765)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4989)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 42 more

网上给的答案都是调整 Xss 参数,其实不是正确的做法,

-Xss:每个线程的 Stack 大小,“-Xss 15120”这使得 tomcat 每减少一个线程(thread) 就会立刻耗费 15M 内存,而最佳值应该是 128K, 默认值如同是 512k.

具体报错如下

Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [] 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.ASN1EncodableVe
ctor]

因为 tomcat 启动会去扫描 jar 包,看错误信息 org.bouncycastle.asn1.ASN1EncodableVector,是出在这个类

这个相似呈现在 bcprov*.jar 这个包

所以在 tomcat 的 conf 目录外面 catalina.properties 的文件,

在 tomcat.util.scan.DefaultJarScanner.jarsToSkip= 外面加上 bcprov*.jar 过滤

启动不会报错了

或者降级 tomcat 版本(相对解决)
借鉴:https://www.cnblogs.com/miaoy…

退出移动版