java.lang.VerifyError 使用 tomcat 启动 spring 启动应用程序

java.lang.VerifyError while starting spring boot app using tomcat

ERROR [org.springframework.web.context.ContextLoader:313] - Context initialization failed
java.lang.VerifyError: (class: org/springframework/core/type/StandardAnnotationMetadata, method: getAnnotationTypes signature: ()Ljava/util/Set;) Illegal type in constant pool
    at org.springframework.core.type.AnnotationMetadata.introspect(AnnotationMetadata.java:127)
    at org.springframework.context.annotation.ConfigurationClassUtils.dt_133_checkConfigurationClassCandidate_98(ConfigurationClassUtils.java)
    at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:108)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:276)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:629)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    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)

这在一个部署环境中发生,而在其他 VM 上运行良好。 两个虚拟机都具有相同版本的 JDK、tomcat 和 spring 版本。

我找不到发生这种情况的任何原因。可能是什么问题?

所以在我的例子中,罪魁祸首是 Dynatrace。在运行时 Dynatrace 在 class 文件中执行一些检测以监视修改 java class 字节码的性能。现在,如果 dynatrace 版本与已安装的 runtime JDK 不兼容,我们可能最终会看到如下问题:

warning [native] Error during parsing of java bytecode: Java classes with "invokedynamic" are not supported, skipping class transformation (class java/time/Instant) 

ERROR [org.springframework.web.context.ContextLoader:313] - Context initialization failed
java.lang.VerifyError: (class: org/springframework/core/type/StandardAnnotationMetadata, method: getAnnotationTypes signature: ()Ljava/util/Set;) Illegal type in constant pool
    at 

禁用 Dynatrace 和 re-installing 应用 & JDK 后一切正常。这是在这种情况下可以观察到的问题之一。