1. Environmental information:
Spring 3.2.0, JDK 1.8.0
2. Run a simple program and the following error message appears:
2. Run a simple program and the following error message appears:
- 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)
- ... 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)
- ... 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)
- ... Wuyi more
3. Problem analysis
"ASM Classreader failed to parse class file" is one of the main reasons. Check MAVEN's class library, no problem found, no ASM explicit dependency, its dependency is generated by spring itself. Therefore, the analysis may be the problem caused by spring itself, but so popular spring, how can it be wrong, I can not so bull X encounter such a simple problem?
Is it a version? In addition to the version, Spring has no big difference. After a general search, there are really similar problems on the Internet:
- Note that the Java 8 bytecode level (-target 1.8, as required By-source 1.8) are only fully supported as of Spring Framewo RK 4.0.
- In particular, Spring 3.2 based applications need to BES 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>
So, as you can see, there are two options:
A. Using Jdk7
B. Upgrading Spring 4
4. Problem solving
Finally, the upgrade Spring4.1.7 is selected, and then the problem is resolved.
SPRINGMVC Exception information ASM Classreader failed to parse class file problem solving