簡體   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