Spring MVC Unit Test exception caused By:org.springframework.core.NestedIOException:ASM Classreader failed to parse class file

Source: Internet
Author: User

Sping 3.2.8.RELEASE + sping MVC + JDK 1.8 Run exception.

java.lang.IllegalStateException:Failed to load Applicationcontextat Org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext ( Cacheawarecontextloaderdelegate.java:99) at Org.springframework.test.context.TestContext.getApplicationContext (Testcontext.java:122) at Org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies ( Dependencyinjectiontestexecutionlistener.java:109) at Org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance ( Dependencyinjectiontestexecutionlistener.java:75) at Org.springframework.test.context.TestContextManager.prepareTestInstance (Testcontextmanager.java:307) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest (Springjunit4classrunner.java :211) at org.springframework.test.context.junit4.springjunit4classrunner$1.runReflectiveCall (springjunit4classrunner.java:288) at Org.junit.internal.runners.model.ReflectiveCallable.run (Reflectivecallable.java:15) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock ( Springjunit4classrunner.java:284) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (Springjunit4classrunner.java: 231) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (Springjunit4classrunner.java: 88) at org.junit.runners.parentrunner$3.run (parentrunner.java:231) at org.junit.runners.parentrunner$1.schedule (parentrunner.java:60) at Org.junit.runners.ParentRunner.runChildren (Parentrunner.java:229) at org.junit.runners.parentrunner.access$(parentrunner.java:50) at org.junit.runners.parentrunner$2.evaluate (parentrunner.java:222) at Org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate ( Runbeforetestclasscallbacks.java:61) at Org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate ( Runaftertestclasscallbacks.java:71) at Org.junit.runners.ParentRunner.run (Parentrunner.java:300) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (Springjunit4classrunner.java:174) at Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (Junit4testreference.java:86) at Org.eclipse.jdt.internal.junit.runner.TestExecution.run (Testexecution.java:38) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (Remotetestrunner.java:459) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (Remotetestrunner.java:678) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (Remotetestrunner.java:382) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (Remotetestrunner.java:192) caused By:org.springframework.beans.factory.BeanDefinitionStoreException:Failed to read candidate component class: File [D:\workspace\stockmgt_maven_project\target\classes\com\liaoze\stockmgt\service\impl\UserServiceImpl.class]; Nested exception is Org.springframework.core.NestedIOException:ASM Classreader failed to parseclassFile-probably due to aNewJavaclassFile version that isn ' t supported Yet:file [D:\workspace\stockmgt_maven_project\target\classes\com\liaoze\stockmgt\ Service\impl\userserviceimpl.class]; Nested exception is Java.lang.IllegalArgumentExceptionat 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.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)... 25morecaused By:org.springframework.core.NestedIOException:ASM Classreader failed to parseclassFile-probably due to aNewJavaclassFile version that isn ' t supported Yet:file [D:\workspace\stockmgt_maven_project\target\classes\com\liaoze\stockmgt\ Service\impl\userserviceimpl.class]; Nested exception is Java.lang.IllegalArgumentExceptionat 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)... 48morecaused by:java.lang.IllegalArgumentExceptionat 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
Stack Overflow Search:

The foreigner gives the answer:

Visual is Java 1.8 version only support Spring 4.0 or later, Spring 3.2 can only use Java 7 .... That's probably what it means.

Solution: Either change Java to 1.7 or later, or change spring to 4.0 or more.

Pom.xml to read as follows:

Spring MVC Unit Test exception caused By:org.springframework.core.NestedIOException:ASM Classreader failed to parse class file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.