当前位置: 首页 > 面试题库 >

启动Java项目时发生类冲突:ClassMetadataReadingVisitor具有接口org.springframework.asm.ClassVisitor作为超类

乐正镜
2023-03-14
问题内容

我正在使用最新的Spring框架版本(3.2.2-RELEASE)开发Java Web项目,但是现在在启动项目时遇到了问题。详细错误是

java.lang.IncompatibleClassChangeError:

类org.springframework.core.type.classreading.ClassMetadataReadingVisitor具有org.springframework.asm.ClassVisitor接口作为超类。

我已经在Internet和此站点上研究了此问题,并获得了一些线索。我已经从项目中删除了asm和spring-
asm库,但是没有用。我看到在默认JRE的rt.jar中定义了另一个ClassVisitor接口。这是引起冲突的原因吗?

但我确实意识到:

class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata {

    private String className;
        ....
}

ClassMetadataReadingVisitor引用class org.springframework.asm.ClassVisitor(已在spring-
core软件包中提供),那么它如何与com.sun.xml.internal.ws.org.objectweb.asm.ClassVisitorJRE
的接口冲突?我不知道怎么会这样?

这是完整的堆栈跟踪:

[ERROR 13:49:39] (ContextLoader:319) - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\workspace\.projects\myproject\trunk\target\myproject\WEB-INF\classes\com\myproject\action\AuthenticationAction.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:281)
    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.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:389)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
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)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:63)
    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:257)
    ... 47 more
[ERROR 13:49:39] (ContextLoader:319) - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\workspace\.projects\myproject\trunk\target\myproject\WEB-INF\classes\com\myproject\action\AuthenticationAction.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:281)
    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.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:389)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
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)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:63)
    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:257)
    ... 47 more

这是依赖项列表:

activation-1.0.2.jar  
antlr-2.7.7.jar  
antlr-runtime-3.3.jar  
arena-0.1.jar  
asm-3.3.1.jar (removed from classpath)  
aspectjweaver.jar  
bcprov-jdk16-145.jar  
c3p0-0.9.1.2.jar  
cglib-2.1_3.jar  
com.springsource.org.apache.xml.serializer-2.7.1.jar  
commons-beanutils-1.8.3.jar  
commons-codec-1.7.jar  
commons-collections-3.2.1.jar  
commons-dbcp-1.4.jar  
commons-digester-2.1.jar  
commons-fileupload-1.2.2.jar  
commons-httpclient-3.1.jar  
commons-io-2.4.jar  
commons-lang-2.6.jar  
commons-logging-1.1.1.jar  
commons-pool-1.6.jar  
commons-vfs-patched-1.9.1.jar  
commons-vfs2-2.0.jar  
csv.jar  
dom4j-1.6.1.jar  
fop-1.0.jar  
gson-2.2.2.jar  
htmlcleaner-2.4.jar  
httpclient-4.2.3.jar  
httpcore-4.2.3.jar  
httpcore-nio-4.2.3.jar  
httpmime-4.2.3.jar  
jaxen-1.1-beta-6.jar  
jcifs-1.3.15.jar  
jdom-1.0.jar  
jersey-client-1.8.jar  
jersey-core-1.8.jar  
jersey-multipart-1.0.3.144640.jar  
jersey-server-1.8.jar  
jersey-spring-1.8.jar  
joda-time-2.2.jar  
joda-time-jsptags-1.1.1.jar  
jodconverter-2.2.2.jar  
json-lib-2.4-jdk15.jar  
json-simple-1.1.1.jar  
json-taglib-0.4.1.jar  
jsoup-1.7.2.jar  
jstl-1.2.jar  
juh-3.2.1.jar  
jurt-3.2.1.jar  
log4j-1.2.17.jar  
mail-1.4.5.jar  
persistence-api-1.0.2.jar  
poi-3.9.jar  
poi-ooxml-3.9.jar  
poi-ooxml-schemas-3.9.jar  
poi-scratchpad-3.9.jar  
postgresql-9.1-901-1.jdbc4.jar  
quartz-2.1.6.jar  
ridl-3.2.1.jar  
scribe-1.3.3.jar  
slf4j-api-1.7.5.jar  
slf4j-jdk14-1.7.5.jar  
spring-aop-3.2.2.RELEASE.jar  
spring-asm-3.1.4.RELEASE.jar (removed from classpath)  
spring-beans-3.2.2.RELEASE.jar  
spring-context-3.2.2.RELEASE.jar  
spring-context-support-3.2.2.RELEASE.jar  
spring-core-3.2.2.RELEASE.jar  
spring-expression-3.2.2.RELEASE.jar  
spring-jdbc-3.2.2.RELEASE.jar  
spring-tx-3.2.2.RELEASE.jar  
spring-web-3.2.2.RELEASE.jar  
spring-webmvc-3.2.2.RELEASE.jar  
standard-1.1.2.jar  
stax-api-1.0.1.jar  
stringtemplate-4.0.2.jar  
unoil-3.2.1.jar  
velocity-1.7.jar  
velocity-tools-2.0.jar  
wmf2svg-0.9.3.jar  
xalan-2.7.1.jar  
xercesImpl-2.11.0.jar  
xml-apis-1.4.01.jar  
xmlbeans-2.6.0.jar  
xmlgraphics-commons-1.5.jar  
xstream-1.4.4.jar

问题答案:

我通过重新排序pom依赖项解决了相同的问题。

我从org.springframework.security获得问题。所以我把它带到了依赖关系的尽头。



 类似资料:
  • 当我尝试在Eclipse中启动Server Tomcat 8时,我有以下错误: Java运行时环境检测到致命错误: pc=0x00007ffd233a2bbd,pid=6852,tid=3720 JRE版本:Java(TM)SE运行时环境(8.0_66-b18)(构建1.8.0_66-b18)Java虚拟机:Java热点(TM)64位服务器虚拟机(25.66-b18混合模式windows-amd6

  • 问题内容: 如果我们需要实现两个接口,这两个接口都包含一个具有相同名称和参数但返回类型不同的方法,我们该怎么办?例如: 有没有简单的方法可以解决此问题? 问题答案: 最简单的解决方案是始终返回A,因为它可以存储所有可能的值。 如果您不是一个选择,则需要使用继承的替代方法。

  • 我正在从国家美术馆的在线目录中检索信息。由于目录的结构,我无法通过提取和跟踪条目之间的链接来导航。幸运的是,集合中的每个对象都有一个可预测的url。我希望我的爬行器通过生成开始URL来导航集合。 我试图通过实现这个线程中的解决方案来解决我的问题。不幸的是,这似乎打破了我蜘蛛的另一部分。错误日志显示我的网址正在成功生成,但它们没有被正确处理。如果我正确地解释了日志——我怀疑我没有——在重新定义允许我

  • 我有两个顶级班;每个都有一个同名的内部类: 我的期望是最终得到四个类文件,包括一个$TestCase。类和B$TestCase。类,这是我从命令行编译时得到的。然而,Eclipse只是创建了测试用例。类,并声明当我尝试编译B.java时“类型TestCase已经定义”。 是否有一个Eclipse选项,我可以设置为生成(我认为是标准的)A$TestCase.class和B$TestCase.clas

  • 在Java8中,如果我有两个具有不同(但兼容)返回类型的接口,反射告诉我这两个方法中的一个是默认方法,即使我实际上没有将该方法声明为默认方法或提供方法体。 例如,以以下代码段为例: Java 1.8生成以下输出: 这看起来很奇怪,不仅因为这两种方法都存在,还因为其中一种方法突然莫名其妙地变成了默认方法。 在Java7中运行相同的代码会产生一些不那么出乎意料的东西,尽管仍然令人困惑,因为这两个方法具

  • 我试图在中使用来创建一个新变量,在这个变量中,我将一些值设置为missing并同时重新编码其他值。 但是,如果尝试将值设置为,则会出现一个错误,说明我们无法创建变量,因为是逻辑的: mutate_impl(.data,dots)中出错: 计算错误:类型必须是double,不是逻辑。 在数据帧的非逻辑向量中,是否有方法使用此设置值?