java.lang.VerifyError在使用Tomcat启动Spring Boot应用时出现问题。

huangapple go评论75阅读模式
英文:

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)

This is happening in one of the deployment environments, whereas it runs fine on the other VM.
Both VMs have the same version of JDK, Tomcat, and Spring versions.

I am not able to find any reason why this is happening. What could be the issue?

英文:
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)

This is happeing in one of the deployment environment whereas it runs fine on other VM.
Both the VMs have same version of JDK, tomcat and spring versions.

I am not able to find any reason why this is happening. What could be the issue?

答案1

得分: 1

所以在我的案例中,罪魁祸首是Dynatrace。在运行时,Dynatrace对类文件进行一些仪器化,以监控性能,这会修改Java类字节码。现在,如果Dynatrace版本与已安装的运行时JDK不兼容,我们可能会遇到以下问题:

警告[native] 解析java字节码时出错:不支持带有“invokedynamic”的Java类,跳过类转换(类java/time/Instant)

或者

错误[org.springframework.web.context.ContextLoader:313] - 上下文初始化失败
java.lang.VerifyError:(类:org/springframework/core/type/StandardAnnotationMetadata,方法:getAnnotationTypes 签名:()Ljava/util/Set;) 常量池中的非法类型
    在

禁用Dynatrace并重新安装应用程序和JDK后,一切都正常工作了。这是在这种情况下可能出现的问题之一。

英文:

So in my case the culprit was Dynatrace. At runtime Dynatrace performs some instrumentation in class files for monitoring performance which modifies the java class bytecode. Now, if dynatrace version in not compatible with installed runtime JDK we might end up seeing issues like:

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

OR

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 

After disabling Dynatrace and re-installing app & JDK everything worked fine. This is one of the issues that can be observed is such scenarios.

huangapple
  • 本文由 发表于 2020年9月12日 19:06:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63859669.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定