class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class

简介:

今天在工作中遇到了下面的问题:

java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:101) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:331) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:213) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:290) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) [junit-4.10.jar:na]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:292) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) [junit-4.10.jar:na]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) [junit-4.10.jar:na]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) [junit-4.10.jar:na]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) [junit-4.10.jar:na]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) [junit-4.10.jar:na]
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300) [junit-4.10.jar:na]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176) [spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157) [junit-4.10.jar:na]
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) [junit-rt.jar:na]
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) [junit-rt.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) [idea_rt.jar:na]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\workspace\github\Timer\target\test-classes\com\rollenholt\timer\Demo.class]; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:301) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadBeanDefinitions(AbstractGenericContextLoader.java:253) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:122) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:250) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91) ~[spring-test-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    ... 28 common frames omitted
Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_25]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_25]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_25]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_25]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_25]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_25]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_25]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_25]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_25]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_25]
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_25]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_25]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:63) ~[spring-core-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:82) ~[spring-core-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) ~[spring-core-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:277) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
    ... 51 common frames omitted

说实话根据这些异常信息一时半会还真没看出是什么原因引起的。Google后在Stackoverflow中发现了同样的问题.

链接地址:http://stackoverflow.com/questions/16209623/incompatibleclasschangeerror-class-classmetadatareadingvisitor-has-interface-cl

问题的原因是因为引入的Spring的版本不对。因为我引入的spring-core的版本是4.0.5.RELEASE,而引入的spring-asm的版本确为3.x的版本。因此版本不一致。

解决办法就是将两个的版本改为一致,我全部改为了4.0.5.RELEASE版本。然后问题解决了。


目录
相关文章
|
4月前
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
101 0
|
7月前
|
Java
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
89 0
swagger遇到的错误记录java.lang.IllegalArgumentException: No enum constant org.springframework.web.bind.anno
swagger遇到的错误记录java.lang.IllegalArgumentException: No enum constant org.springframework.web.bind.anno
171 1
|
分布式计算 Hadoop
SLF4J:Failed to load class org.slf4j.impl.StaticLoggerBinder.
SLF4J:Failed to load class org.slf4j.impl.StaticLoggerBinder.
245 0
|
Java 数据库连接 mybatis
org.apache.ibatis.binding.BindingException: Type interface is not know to the MapperRegistry.
错误原因 没有将映射文件引入到MyBatis的核心文件中。 将映射文件引入即可。
163 0
org.apache.ibatis.binding.BindingException: Type interface is not know to the MapperRegistry.
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
131 0
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
|
JSON Dubbo Java
Failed to meta-introspect annotation interface org.springframework.web.bind.annotation.RequestBody:
Failed to meta-introspect annotation interface org.springframework.web.bind.annotation.RequestBody:
263 0
Failed to meta-introspect annotation interface org.springframework.web.bind.annotation.RequestBody:
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found
116 0
|
Java Android开发
Unable to load class ‘javax.xml.bind.annotation.XmlSchema‘.
Unable to load class ‘javax.xml.bind.annotation.XmlSchema‘.
895 0
Unable to load class ‘javax.xml.bind.annotation.XmlSchema‘.