java.lang.ClassNotFoundException: org.jdom.JDOMException

CodeMed picture CodeMed · Feb 17, 2013 · Viewed 18k times · Source

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

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.

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:

    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?

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:

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.

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

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:

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.

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

Answer

rolfl picture rolfl · Feb 17, 2013

You have the JDOM 2.x version iun your classpath, but the code is looking for version 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.*

See this note: JDOM2 migration

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

Rolf