繁体   English   中英

运行Java App时出现NoSuchMethodError

[英]NoSuchMethodError when Running Java App

当我尝试运行java控制台应用程序时,在Red Hat 5上看到以下错误,但是在Ubuntu上却没有。

另一个StackOverflow 帖子提到不要混合使用spring 2和spring 3。

但是我find [where I run app - includes classpath] | grep spring | grep 3我在find [where I run app - includes classpath] | grep spring | grep 3 find [where I run app - includes classpath] | grep spring | grep 3 find [where I run app - includes classpath] | grep spring | grep 3 ,结果为0。 因此,我认为这不是spring版本的问题。

> Exception in thread "main"
> org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
> Configuration problem: Failed to import bean definitions from URL
> location
> [classpath:/org/eurekastreams/server/conf/applicationContext-model.xml]
> Offending resource: class path resource [conf/applicationContext.xml];
> nested exception is
> org.springframework.beans.factory.BeanDefinitionStoreException:
> Unexpected exception parsing XML document from class path resource
> [org/eurekastreams/server/conf/applicationContext-model.xml]; nested
> exception is java.lang.NoSuchMethodError:org.springframework.aop.config.
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary
(Lorg/springframework/beans/factory/xml/ParserContext;
Lorg/w3c/dom/Element;)V

编辑

添加了堆栈跟踪:

Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V

运行spring-aop.jarmvn dependency:tree ,我看到了spring-aop.jar的几个版本:

$grep "spring-aop" mvn_dependency_tree.txt 
    [INFO] |  +- org.springframework:spring-aop:jar:2.0.8:compile
    [INFO] |  |  |  +- org.springframework:spring-aop:jar:2.0.8:provided
    [INFO] |  |  +- org.springframework:spring-aop:jar:2.0.8:compile
    [INFO] |  |  +- org.springframework:spring-aop:jar:2.5.4:compile

这些不同版本的spring-aop能否从我添加的堆栈跟踪中解释AOP错误?

看起来这里的罪魁祸首是spring-aop的2.0.8版本。

您需要做的是检查依赖关系树的输出(而不是grep),以找出哪些“父”罐对此版本具有依赖关系,因此将其拉到类路径中。 通过删除或升级父jar的版本,您应该能够清除类路径,而保留版本2.5.4。

完成此操作后,重建并运行您的应用程序。

这是有关依赖树的更多信息:

http://maven.apache.org/plugins/maven-dependency-plugin/index.html

http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM