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?
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.