Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported - Am using Apache 7 and JDK 1.8

Am getting the below error **ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet **

Am using JDK 1.8 and Apache 7 and am using Spring 3.2.9 versionto run my web project

[jar:file:/apps/tomcat/instances/tomcat01/work/Catalina/localhost/ConcurArchival_Web/WEB-INF/lib/ecl-test-1.0.0.jar!/com/tgt/ecl/framework/test/MVCTest.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: URL 

Help appreciated from veterans

Stack Trace added below:

 SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/apps/tomcat/instances/tomcat01/work/Catalina/localhost/ConcurArchival_Web/WEB-INF/lib/tgt-ecl-test-1.0.0.jar!/com/tgt/ecl/framework/test/MVCTest.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: URL [jar:file:/apps/tomcat/instances/tomcat01/work/Catalina/localhost/ConcurArchival_Web/WEB-INF/lib/tgt-ecl-test-1.0.0.jar!/com/tgt/ecl/framework/test/MVCTest.class]; nested exception is java.lang.IllegalArgumentException
       at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290)
       at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
       at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
       at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
       at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
       at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
       at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:195)
       at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
       at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
       at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
       at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
       at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
       at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
       at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
       at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
       at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
       at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
       at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
       at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
       at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
       at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
       at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
       at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
       at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
       at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:663)
       at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1642)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: URL [jar:file:/apps/tomcat/instances/tomcat01/work/Catalina/localhost/ConcurArchival_Web/WEB-INF/lib/tgt-ecl-test-1.0.0.jar!/com/tgt/ecl/framework/test/MVCTest.class]; nested exception is java.lang.IllegalArgumentException
       at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:56)
       at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
       at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
       at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266)
       ... 36 more
Caused by: java.lang.IllegalArgumentException
       at org.springframework.asm.ClassReader.<init>(Unknown Source)
       at org.springframework.asm.ClassReader.<init>(Unknown Source)
       at org.springframework.asm.ClassReader.<init>(Unknown Source)
       at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:53)
       ... 39 more

Apr 22, 2016 1:52:31 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Apr 22, 2016 1:52:31 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
       at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
       at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
       at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
       at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
       at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:586)
       at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
       at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
       at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
       at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
       at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
       at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:663)
       at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1642)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
like image 609
Sunil Avatar asked Apr 24 '16 06:04

Sunil


1 Answers

You are using a version of Spring that depends on a version of ASM that doesn't support code compiled with Java 8 compilers. You need to upgrade to Spring 4.0.3 or later.

https://spring.io/blog/2014/03/27/spring-framework-4-0-3-released-with-java-8-support-now-production-ready

You might get away with doing a point update of the ASM library, but that is liable to introduce compatibility problems between Spring and ASM. Upgrading Spring is a better idea. You get the opportunity to use the new features in Spring 4.x, and migration to 5.x and beyond is easier.


Someone suggested an alternative approach: roll back your runtime and build platforms to Java 7. That may work in the short term, but you are just putting off upgrading .... and making the upgrades a bigger problem to solve when you are forced to solve them.


Apparently, you can also get this if you are using a mixture of Spring versions, presumably some of them older than Spring 4.0.3, with Java 8 and later.

like image 100
Stephen C Avatar answered Oct 30 '22 18:10

Stephen C