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

2jcobegt  于 2023-06-23  发布在  Spring
关注(0)|答案(1)|浏览(127)

我得到这个错误:
ASM ClassReader无法解析类文件-可能是由于新的Java类文件版本尚不受支持
我正在使用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

感谢退伍军人的帮助
添加了以下堆栈跟踪:

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

rryofs0p1#

您使用的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
您可能会对ASM库进行点更新,但这可能会在Spring和ASM之间引入兼容性问题。升级Spring是一个更好的主意。您有机会使用Spring 4.x中的新特性,迁移到5.x及更高版本更容易。
有人提出了另一种方法:将运行时和构建平台回滚到Java 7。这可能在短期内有效,但你只是推迟升级。并使升级成为一个更大的问题,以解决当你被迫解决他们。
显然,如果您使用的是Spring版本的混合,可能其中一些版本比Spring 4.0.3更早,以及Java 8及更高版本,您也可以得到这一点。

相关问题