java.lang.ClassNotFoundException: org.jdom.JDOMException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14918347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 17:50:53  来源:igfitidea点击:

java.lang.ClassNotFoundException: org.jdom.JDOMException

javarssjdomrome

提问by CodeMed

I am getting the following error message when trying to load an rss page:

尝试加载 rss 页面时,我收到以下错误消息:

Feb 16, 2013 9:08:44 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [news-feed] in context with path [/publisher] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.jdom.JDOMException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at com.sun.syndication.io.SyndFeedOutput.<init>(SyndFeedOutput.java:44)

The line of code which triggers the error is:

触发错误的代码行是:

    SyndFeedOutput output = new SyndFeedOutput();  

I have googled this error message and read several postings about it, including postings on this site. Those postings suggest that adding jdom.jar to the build path will cause the error to go away. However, I have added all 8 of the jar files that come bundled with jdom-2.0.4.jar to my buildpath in eclipse, but the error message still persists each time I try to load the rss page.

我在谷歌上搜索了这条错误信息,并阅读了几篇关于它的帖子,包括这个网站上的帖子。这些帖子表明将 jdom.jar 添加到构建路径将导致错误消失。但是,我已将与 jdom-2.0.4.jar 捆绑在一起的所有 8 个 jar 文件添加到 eclipse 中的构建路径中,但每次尝试加载 rss 页面时错误消息仍然存在。

I am wondering if the problem might be with the fact that I am using jdom-2.0.4.jar with what might be older syntax of:

我想知道问题是否可能出在我使用 jdom-2.0.4.jar 和以下可能是旧语法的事实上:

    SyndFeedOutput output = new SyndFeedOutput();  

The other postings for this error message were all from older versions of jdom. Perhaps there is some new syntax for calling the equivalent of SyndFeedOutput() in the new version of jdom?

此错误消息的其他帖子均来自旧版本的 jdom。也许有一些新的语法可以在新版本的 jdom 中调用 SyndFeedOutput() 等价物?

Can anyone help me get past this error message?

谁能帮我解决这个错误信息?

EDIT:

编辑:

To address Nocmear's suggestion, I have confirmed that the following 9 jar files are the only jar files related to jdom or rome that are included in the buildpath for my application:

为了解决 Nocmear 的建议,我已确认以下 9 个 jar 文件是我的应用程序的构建路径中包含的唯一与 jdom 或 rome 相关的 jar 文件:

jaxen-1.1.4.jar  
jdom-2.0.4.jar  
jdom-2.0.4-contrib.jar  
jdom-2.0.4-javadoc.jar  
jdom-2.0.4-junit.jar  
jdom-2.0.4-sources.jar  
rome-1.0.jar  
xercesImpl.jar  
xml-apis.jar  

SECOND EDIT:

第二次编辑:



I downloaded jdom-1.1.3 and added it to my application's buildpath in eclipse, as rolfl suggested.

我下载了 jdom-1.1.3 并将它添加到我在 eclipse 中的应用程序的构建路径中,正如 rolfl 所建议的那样。

When I went to load the rss page in my web browser, tomcat gave me the following error log:

当我在我的网络浏览器中加载 rss 页面时,tomcat 给了我以下错误日志:

java.lang.NoClassDefFoundError: org/jdom/JDOMException
    com.sun.syndication.io.SyndFeedOutput.<init>(SyndFeedOutput.java:44)
    publisher.web.NewsFeedServlet.doGet(NewsFeedServlet.java:68)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

java.lang.ClassNotFoundException: org.jdom.JDOMException
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    com.sun.syndication.io.SyndFeedOutput.<init>(SyndFeedOutput.java:44)
    publisher.web.NewsFeedServlet.doGet(NewsFeedServlet.java:68)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

The relevant jar files now included in my buildpath are:

现在包含在我的构建路径中的相关 jar 文件是:

ant.jar  
jaxen.jar  
jaxen 1.1.4.jar  
jdom-2.0.4.jar  
jdom-2.0.4-contrib.jar  
jdom-2.0.4-javadoc.jar  
jdom-2.0.4-junit.jar  
jdom-2.0.4-sources.jar  
rome-1.0.jar  
xalan.jar  
xerces.jar  
xercesImpl.jar  
xml-apis.jar  

Also, I tried adding these jars to the bin file in tomcat instead as per Nocmear's suggestion, but that just triggered error messages in eclipse, so I put them back in the eclipse appication.

另外,我尝试按照 Nocmear 的建议将这些 jar 添加到 tomcat 中的 bin 文件中,但这只是在 eclipse 中触发了错误消息,所以我将它们放回了 eclipse appication 中。

Perhaps I am not understanding what people are suggesting. Or perhaps someone might have other suggestions. Any help is appreciated.

也许我不明白人们的建议。或者也许有人可能有其他建议。任何帮助表示赞赏。

回答by rolfl

You have the JDOM 2.x version iun your classpath, but the code is looking for version 1.x.

您在类路径中拥有 JDOM 2.x 版本,但代码正在寻找 1.x 版本。

Download JDOM 1.1.3 and put that in your classpath together with one(the latest) version of JDOM 2.x. All packages in JDOM 1.x are org.jdom.* ... and all packages in JDOM 2.x are org.jdom2.*

下载 JDOM 1.1.3 并将其与JDOM 2.x 的一个(最新)版本一起放在您的类路径中。JDOM 1.x 中的所有包都是 org.jdom.* ... JDOM 2.x 中的所有包都是 org.jdom2.*

See this note: JDOM2 migration

请参阅此说明:JDOM2 迁移

and the front page of the JDOM site: read down to the Project Status

和 JDOM 站点的首页:向下阅读项目状态

Rolf

罗尔夫

回答by Xiangyu

M8, rome-1.0 depends on jdom-1.0.

M8,rome-1.0依赖jdom-1.0。

So you may want to change use jdom-1.0.jar instead of jdom-2.0.x ro jdom-1.1.3.

所以你可能想要改变使用 jdom-1.0.jar 而不是 jdom-2.0.x ro jdom-1.1.3。

回答by Nocmear

Please check the version of the jar. You may import two jars, one old and one new, then you remove the old one, or download the newest jar.

请检查jar的版本。您可以导入两个 jar,一个旧的和一个新的,然后删除旧的,或者下载最新的 jar。