ASM ClassReader 无法解析类文件 - 可能是由于不支持新的 Java 类文件版本 - 我使用的是 Apache 7 和 JDK 1.8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36820068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:53:52  来源:igfitidea点击:

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

javaspring-mvc

提问by Sunil

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 **

我收到以下错误 **ASM ClassReader 无法解析类文件 - 可能是由于尚不支持的新 Java 类文件版本 **

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

我使用 JDK 1.8 和 Apache 7 并且使用 Spring 3.2.9 版本来运行我的 web 项目

[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)

采纳答案by Stephen C

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.

您使用的 Spring 版本依赖于不支持使用 Java 8 编译器编译的代码的 ASM 版本。您需要升级到 Spring 4.0.3 或更高版本。

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

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

You mightget 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.

可能不会对 ASM 库进行点更新,但这很容易在 Spring 和 ASM 之间引入兼容性问题。升级 Spring 是一个更好的主意。您有机会使用 Spring 4.x 中的新功能,并且更容易迁移到 5.x 及更高版本。



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.

有人提出了另一种方法:回滚您的运行时并将平台构建到 Java 7。这可能在短期内奏效,但您只是推迟升级......并且在您被迫时使升级成为需要解决的更大问题解决它们。



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.

显然,如果您混合使用 Spring 版本(大概其中一些版本早于 Spring 4.0.3,Java 8 及更高版本),您也可以获得此信息。