• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot load xerces SAXParser

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have some serious problems with Xerces2 Java Parser 2.9.1.

I am using Apache Tomcat/5.5.25 JVM 1.5.0_16-b02.

I just downloaded Xerces2 version 2.9.1. I copied the following jar files into the library called: /apache-tomcat-5.5.25/shared/lib/ :

resolver.jar
serializer.jar
xercesImpl.jar
aml-apis.jar

When I restart the container it seems to work fine. But it only works until I reload my application using Tomcat Web Application Manager. Then I get this error:
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser

I have searched the internet to solve the problem. It seems that several people have experienced the same problem, but I´m not sure how to work around this issue.

Any help please would be appreciated?

Log print from wrapper.log:

 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you explicitly using Xerces version 2.9.1 as a shared library? The JAXP 1.3 implementation included the Java release you're using already uses the Xerces parser (albeit version 2.6.2) by default.
From the log file I see you're using the JDOM API. Itss SAXBuilder class will, by default, use JAXP to retrieve a parser. So based on just this information I don't really see the need to include the shared library.
Shared libraries are something to be very cautious about anyway, but especially in case of an XML parser implementation.
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it works now :-)

I removed the file called xercesImpl.jar. Then I added a previous installed jar file called xerces.jar and it works now.


Jelle Klap wrote:Why are you explicitly using Xerces version 2.9.1 as a shared library? The JAXP 1.3 implementation included the Java release you're using already uses the Xerces parser (albeit version 2.6.2) by default.
From the log file I see you're using the JDOM API. Itss SAXBuilder class will, by default, use JAXP to retrieve a parser. So based on just this information I don't really see the need to include the shared library.
Shared libraries are something to be very cautious about anyway, but especially in case of an XML parser implementation.
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I just realized, that I still have a problem with my code.

As mentioned in my previous message I tried to remove all the jar files from Xerces version 2.9.1 package. I removed the following files from tomcat/shared/lib and restarted the container:

xercesImpl.jar.
xml-apis.jar
serializer.jar
resolver.jar

I also removed xerces.jar from tomcat/shared/lib

Without xerces.jar (after restarting the container) and got the following an error:

I then added the xerces.jar again and it works until I restart the application with Tomcat web application manager. Now I get the following errors:


It seems to be a org.jdom.JDOMException:
- Could not load org.apache.xerces.parsers.SAXParser: SAX2 driver class org.apache.xerces.parsers.SAXParser not found...

I'm not sure how to work around this issue? As I understood on the last reply, I was told to remove the Xerces package,
because the JDOM API by default is using the JAXP to retrieve a parser. I removed the Xerces version 2.9.1 package,
but is still getting a org.jdom.JDOMException?

Here is some of the other jar files placed in the tomcat/shared/lib:

xml-apis.jar
xerces.jar
xalan.jar
saxpath.jar
jdom.jar
jaxrpc.xml
jaxen-jdom.jar
jaxen-core.jar
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need any of those dependency libraries I think.
JAXP 1.3 includes a SAX 2.0.2 parser, which JDOM requires (the Xerces dependency), but it also supports XPath and XSLT (the Jaxen and Xalan dependency JARs).
I'm prretty sure you can clear the shared/lib folder completely of JDOM dependencies. Also, I'd suggest moving the jdom.jar file itself to the WEB-INF/lib folder of the specific web application(s) that require(s) it, instead of making it a shared library.
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I faced with the same issue when trying to pass an XML file using org.apache.xerces.parsers.SAXParser.

After goggling for a while came with the below solution.

I downloaded the latest release of Xerces-J-bin.X.XX.X.zip and copied the xercesImpl.jar to the ext folder under jre6.

1. In my case I download Xerces-J-bin.2.11.0.zip from http://www.apache.org/dist/xerces/j/Xerces-J-bin.2.11.0.zip URL.

2. Unzipped and copy the xercesImpl.jar file to C:\Program Files\Java\jre6\lib\ext

Please note, this can be accomplished by adding the xercesImpl.jar into your class-path as a dependency as well.
 
John McDonnell
Greenhorn
Posts: 6
Netbeans IDE Opera Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isuru chamarasinghe wrote:I faced with the same issue when trying to pass an XML file using org.apache.xerces.parsers.SAXParser.

After goggling for a while came with the below solution.

I downloaded the latest release of Xerces-J-bin.X.XX.X.zip and copied the xercesImpl.jar to the ext folder under jre6.

1. In my case I download Xerces-J-bin.2.11.0.zip from http://www.apache.org/dist/xerces/j/Xerces-J-bin.2.11.0.zip URL.

2. Unzipped and copy the xercesImpl.jar file to C:\Program Files\Java\jre6\lib\ext

Please note, this can be accomplished by adding the xercesImpl.jar into your class-path as a dependency as well.


I've tried adding it to my class path and I was having no luck. I then spotted this post, and stuck the jar in the lib/ext folder and everything worked.

How do you mean "into your class-path as a dependency"
 
KiranPatel JavaKnowledge
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was facing the same issue, It was solved only when I replaced xerces-1.4.jar file with a newer version xerces-2.6.2 jar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic