Tomcat 部署 Vaadin 时出现堆栈溢出错误 war

Tomcat stack overflow error when deploying a Vaadin war

在“生产模式”(使用 Vaadin 19.0.9 和 gradle)中生成“war”文件(大小为 90 MB)后,[=27 中的部署过程=] 9.0.52 非常慢并显示此错误

Unable to complete the scan for annotations for web application [/WEBPROP] due to a WhosebugError. 
Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. 
The class hierarchy being processed was
  [org.bouncycastle.asn1.ASN1OutputStream->org.bouncycastle.asn1.DEROutputStream->org.bouncycastle.asn1.ASN1OutputStream]

这个错误经常出现,但并非总是如此。

tomcat 服务器 运行 在 Ubuntu 18 中,具有 8 GB 的 RAM。 java 版本为 15.0.2(这台计算机和用于开发的计算机)。

有什么想法吗?谢谢

PS:这是堆栈跟踪:

java.lang.IllegalStateException: Error starting child

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)

    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)

    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)

    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)

    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)

    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:825)

    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)

    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)

    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)

    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)

    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)

    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)

    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946)

    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)

    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)

    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)

    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)

    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.startup.Catalina.start(Catalina.java:772)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)

    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.base/java.lang.reflect.Method.invoke(Method.java:564)

    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)

    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WEBPROP]]

    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)

    ... 37 more

java.lang.IllegalStateException: Error starting child

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)

    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)

    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)

    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)

    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)

    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:825)

    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)

    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)

    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)

    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)

    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)

    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)

    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946)

    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)

    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)

    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)

    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)

    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    at org.apache.catalina.startup.Catalina.start(Catalina.java:772)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)

    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.base/java.lang.reflect.Method.invoke(Method.java:564)

    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)

    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WEBPROP]]

    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)

    ... 37 more

Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/WEBPROP] due to a WhosebugError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was [org.bouncycastle.asn1.ASN1OutputStream->org.bouncycastle.asn1.DEROutputStream->org.bouncycastle.asn1.ASN1OutputStream]

    at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2404)

    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2342)

    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2294)

    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:2264)

    at org.apache.catalina.startup.ContextConfig.scanWebXmlFragment(ContextConfig.java:2172)

    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:2152)

    at org.apache.catalina.startup.ContextConfig.processClasses(ContextConfig.java:1408)

    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1303)

    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:986)

    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:303)

    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    ... 38 more

Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/WEBPROP] due to a WhosebugError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was [org.bouncycastle.asn1.ASN1OutputStream->org.bouncycastle.asn1.DEROutputStream->org.bouncycastle.asn1.ASN1OutputStream]

    at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2404)

    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2342)

    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2294)

    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:2264)

    at org.apache.catalina.startup.ContextConfig.scanWebXmlFragment(ContextConfig.java:2172)

    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:2152)

    at org.apache.catalina.startup.ContextConfig.processClasses(ContextConfig.java:1408)

    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1303)

    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:986)

    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:303)

    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

    ... 38 more

This Whosebug question 似乎是针对同一个问题。据此,问题可能是 DEROutputStream 由两个不同的 JAR 提供,例如 bcprov-jdk15on-1.47.jarbcprov-jdk16-1.45.jar。那样的话,就需要排除一个。

另外值得一提的是,Vaadin 19不再接收更新,最新维护的版本是20和21即将发布,强烈建议升级。