异常信息ASM ClassReader failed to parse class file的问题解决

原创 2015年12月02日 16:56:56

引言:  在基于Spring开发中碰到了一个异常,并解决之。

1.  环境信息:

   Spring 3.2.10,  JDK 1.8, Hibernate 4

2.  运行简单的程序,出现以下错误信息:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\NewWorkSpace\ep-user\target\test-classes\org\homework\ep\user\base\BaseTest.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: file [D:\NewWorkSpace\ep-user\target\test-classes\org\homework\ep\user\base\BaseTest.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:185)
	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.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadBeanDefinitions(AbstractGenericContextLoader.java:233)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:117)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
	at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
	at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
	... 25 more
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: file [D:\NewWorkSpace\ep-user\target\test-classes\org\homework\ep\user\base\BaseTest.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)
	... 48 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)
	... 51 more

3. 问题分析

  “ASM ClassReader failed to parse class file”是其中主要的原因。检查Maven的类库,没有发现问题,无asm显性依赖,其依赖产生于spring本身。故分析有可能是spring本身的问题造成了;但是这么流行的spring,怎么会出错了,我不能这么牛x碰到这么简单的问题吧?

   难道是版本?除了版本之外,spring无大区别。经过一般搜索,网上还真有类似的问题:

Note that the Java 8 bytecode level (-target 1.8, as required by -source 1.8) is only fully supported as of Spring Framework 4.0. 
In particular, Spring 3.2 based applications need to be compiled with a maximum of Java 7 as the target, 
even if they happen to be deployed onto a Java 8 runtime. <span style="font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;color:#222222;font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(255, 249, 227);">Please upgrade to Spring 4 for Java 8 based applications.</span>
所以,看明白了吧,方案有两条:

   a.  使用jdk7  

   b.  升级spring 4

4.  问题解决

   最终选择了升级Spring4, 然后问题解决。

tomcat启动报错 ASM ClassReader failed to parse class file

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c...
  • cs1075341779
  • cs1075341779
  • 2016年09月23日 18:06
  • 3060

org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file

之前项目没有问题,前几天把jdk升级到1.8后,编译的jar包运行出错 org.springframework.beans.factory.BeanDefinitionStoreException:...
  • hueason
  • hueason
  • 2017年06月15日 10:55
  • 1146

Java 1.8 ASM ClassReader failed to parse class file - probably due to a new Java class file version

环境 java8 + Spring 3.2.4 编译 java7运行出错:org.springframework.core.NestedIOException: ASM ClassReader fa...
  • GG584741
  • GG584741
  • 2016年03月29日 17:21
  • 361

Spring Boot【原理分析】(3)——BeanDefinition

一、简介BeanDefinition描述了一个Bean的实例,包括属性,构造方法参数,注解等更多信息。为后面实例化Bean提供元数据依据。 BeanDefinition的实现类有: 1. Root...
  • wwmfeng
  • wwmfeng
  • 2016年12月16日 13:24
  • 714

项目导入Tomcat,启动报错ASM ClassReader failed to parse class file - probably due to a new Java class file ve

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c...
  • lijunfan_rh
  • lijunfan_rh
  • 2017年01月05日 09:14
  • 660

ASM ClassReader failed to parse class file

ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn’...
  • Gethin_H
  • Gethin_H
  • 2017年07月11日 11:16
  • 305

11.2.0.3+ASM 安装报 ohasd failed to start

# /g01/grid/asm/root.sh Performing root user operation for Oracle 11g The following environment v...
  • rgb_rgb
  • rgb_rgb
  • 2012年12月27日 21:24
  • 7063

ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn'

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c...
  • melour123
  • melour123
  • 2017年03月08日 21:43
  • 123

SpringMVC系列练习的输入网址报错ASM ClassReader failed to parse class file -

1.报错内容 org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - pro...
  • Pruett
  • Pruett
  • 2017年07月21日 09:30
  • 242

异常信息ASM ClassReader failed to parse class file的问题解决

引言:  在基于spring开发中碰到了一个异常,并解决之。 1.  环境信息:    Spring 3.2.10,  JDK 1.8, hibernate 4 2.  运行简单的程序,出现...
  • zoubf
  • zoubf
  • 2016年04月25日 17:53
  • 1024
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:异常信息ASM ClassReader failed to parse class file的问题解决
举报原因:
原因补充:

(最多只允许输入30个字)