tomcat7启动报错too low setting for -Xss

  今天在搭建新的maven项目的时候突然一直遇到一个报错,偶尔又可以启动,至于为什么偶尔又可以启动,现在还不明白原理。具体报错如下

Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/kgclient] 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:2109)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2056)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1931)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1897)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1882)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1314)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:873)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:371)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more

五月 07, 2020 3:43:34 下午 org.apache.catalina.core.ContainerBase startInternal
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more

在网上找了很多原因,最终定位到是tomcat7的-Xss的一个默认配置。-Xss:每个线程的Stack大小,“-Xss 15120” 这使得tomcat每增加一个线程(thread)就会立即消耗15M内存,而最佳值应该是128K,默认值好像是512k. 从报错来看应该是ASN1EncodableVector和DEREncodableVector的bcprov jar,middleobject-1.0.0.jar,tika-app-1.3.jar包下产生了循环继承,所以形成死循环,造成内存溢出。

解决方法有2种:

1、找到tomcat的conf目录里面catalina.properties的文件,在tomcat.util.scan.DefaultJarScanner.jarsToSkip=里面加上bcprov*.jar,,middleobject*.jar,tika-*.jar,过滤(这里tomcat下的这个文件里面默认有很多的忽略加载的jar包。
2、升级tomcat。
我使用的是第一种方法,第二种方法没试过。
posted @ 2020-05-07 15:59  橘子和西红柿  阅读(1026)  评论(0编辑  收藏  举报