java.lang.ClassNotFoundException: org.jdom.JDOMException
Asked Answered
P

3

5

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.

Pyrogenous answered 17/2, 2013 at 5:44 Comment(0)
U
5

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

Unmade answered 17/2, 2013 at 13:34 Comment(2)
Thank you for what sounds like a great catch. +1 for trying to help. Perhaps I am not understanding what you suggest, because I am still getting an error message after I downloaded 1.1.3 from the jdom web site and added the jar files to my buildpath in eclipse. I added the new error message and the list of jar files to my posting above. I just dragged the jar files into eclipse and used eclipse to add them to the build path. I did not import the non-jar files from the download because I never learned to do that. Any other suggestions?Pyrogenous
The same line of code is triggering the error now as before, as shown in my posting above.Pyrogenous
W
3

M8, rome-1.0 depends on 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.

Wickham answered 23/4, 2013 at 4:36 Comment(0)
T
1

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.

Teran answered 17/2, 2013 at 5:53 Comment(2)
Thanks for the suggestion. +1 for trying to help. However, I do not have older versions of the jars imported. To elaborate, I have edited my posting above to include a list of all relevant jars included in my buildpath. Do you have any other suggestions?Pyrogenous
Does the classpath be overwritten? If the tomcat didn't reload the jar, put the jar into the directory tomcat/lib. If the project is being developed with eclipse, recompile it.Teran

© 2022 - 2024 — McMap. All rights reserved.