spring-security-core 2.0.3 spring-aop 2.0.8 导致 NoSuchMethodError

spring-security-core 2.0.3 spring-aop 2.0.8 cause NoSuchMethodError

使用 Maven 在 windows 下构建我的项目工作正常,但是当通过 bamboo 将它部署到 Linux 服务器时,在两台服务器上似乎没问题,但在第三台服务器上我得到一个 NoSuchMethodError 关于一个spring 个库。如果我从 war 中删除 spring-aop:jar,它就可以工作。 İf 是因为 spring 版本不同 如何在其他两个 linux 服务器上工作?

有没有人以前遇到过这个问题,或者对我如何进一步调试这个错误有什么建议?

如有任何帮助,我们将不胜感激。

图书馆树

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ pqis-op ---
[INFO] com.toyotatr.tmem.pqis:pqis-op:war:0.0.1.7-SNAPSHOT
[INFO] +- com.toyotatr.tmem.pqis:pqis-service:jar:0.0.1-SNAPSHOT:compile
[INFO] |  +- com.toyota.tme.jpa:jpa-support:jar:1.1tk:compile
[INFO] |  +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
[INFO] |  |  +- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
[INFO] |  |  +- org.hibernate:hibernate-commons-     annotations:jar:3.1.0.GA:compile
[INFO] |  |  +- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
[INFO] |  |  |  \- antlr:antlr:jar:2.7.6:compile
[INFO] |  |  \- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |     \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile
[INFO] |  |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  |  \- javassist:javassist:jar:3.4.GA:compile
[INFO] |  +- aspectj:aspectjrt:jar:1.5.3:compile
[INFO] |  +- aspectj:aspectjweaver:jar:1.5.3:compile
[INFO] |  +- cglib:cglib:jar:2.2:compile
[INFO] |  |  \- asm:asm:jar:3.1:compile
[INFO] |  +- javax.activation:activation:jar:1.1:compile
[INFO] |  +- javax.mail:mail:jar:1.4.2:compile
[INFO] |  \- net.sf.ehcache:ehcache:jar:1.5.0:compile
[INFO] |     +- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[INFO] |     \- net.sf.jsr107cache:jsr107cache:jar:1.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.5.6:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.6:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.springframework:spring:jar:2.5.6:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-context:jar:2.5.6:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework:spring-beans:jar:2.5.6:compile
[INFO] +- org.springframework:spring-core:jar:2.5.6:compile
[INFO] +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] +- org.springframework:spring-test:jar:2.5.6:test
[INFO] +- org.springframework:spring-webmvc:jar:2.5.6:compile
[INFO] |  +- org.springframework:spring-context-support:jar:2.5.6:compile
[INFO] |  \- org.springframework:spring-web:jar:2.5.6:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- javax.servlet:jstl:jar:1.1.0:compile
[INFO] +- javax.servlet:jsp-api:jar:2.0:compile
[INFO] +- taglibs:standard:jar:1.1.0:compile
[INFO] +- opensymphony:sitemesh:jar:2.4.2:compile
[INFO] +- org.springframework.security:spring-security-core-tiger:jar:2.0.3:compile
[INFO] |  \- org.springframework.security:spring-security-core:jar:2.0.3:compile
[INFO] |     +- org.springframework:spring-aop:jar:2.0.8:compile
[INFO] |     +- org.springframework:spring-support:jar:2.0.8:runtime
[INFO] |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:2.0.3:compile
[INFO] |  \- org.springframework.security:spring-security-acl:jar:2.0.3:compile
[INFO] |     \- org.springframework:spring-jdbc:jar:2.0.8:compile
[INFO] |        \- org.springframework:spring-dao:jar:2.0.8:compile
[INFO] +- org.json:json:jar:20140107:compile
[INFO] +- displaytag:displaytag:jar:1.2:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  +- commons-lang:commons-lang:jar:2.3:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] |  \- org.slf4j:jcl104-over-slf4j:jar:1.4.2:compile
[INFO] +- com.lowagie:itext:jar:2.1.7:compile
[INFO] |  +- bouncycastle:bcmail-jdk14:jar:138:compile
[INFO] |  +- bouncycastle:bcprov-jdk14:jar:138:compile
[INFO] |  \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
[INFO] |     +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
[INFO] |     \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
[INFO] +- junit:junit:jar:4.10:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] \- c3p0:c3p0:jar:0.9.1:compile
[INFO]

错误

[07-05-2015 15:41:27:928] ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext() - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext-main.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:788)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:434)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:780)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:284)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:732)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:282)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:214)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:764)
    at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:145)
    at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
    at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:64)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:605)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:145)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:557)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:232)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
    at org.eclipse.jetty.server.Server.start(Server.java:342)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
    at org.eclipse.jetty.server.Server.doStart(Server.java:290)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.xml.XmlConfiguration.run(XmlConfiguration.java:1250)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V
    at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser$AopAutoProxyConfigurer.configureAutoProxyCreator(AnnotationDrivenBeanDefinitionParser.java:109)
    at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:80)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    ... 53 more

我遇到了您过去描述的问题。这种奇怪的行为是可能的,因为无法保证 class 加载的顺序。因此,有可能同一个 WAR 文件在一台服务器上工作,而在另一台服务器上失败。

调试该问题的简单方法是使用 IDE(如 eclipse 或 intellij)并搜索 AopNamespaceUtilsclass。如果您发现 class 出现两次或更多次,您可以找到包含 class 的罐子并删除这些罐子(class 版本错误的罐子)来自 WAR 文件。

如果您无法使用 IDE 找到它,您可以启用 class 加载程序调试日志并检查 work/not 工作的服务器之间的差异。 (因为您没有提到您正在使用的 servlet container/application 服务器,所以我无法为您提供指导,但使用 google 很容易找到)。