日期:2014-05-16  浏览次数:21227 次

使用DOM4J找不到org/apache/xerces/parsers/SAXParser解决方案
大多数情况下,使用DOM4J用以下两个jar包即可,
dom4j-1.6.1.jar
jaxen-1.1-beta-6.jar

但有时候仅仅有以上两个jar包会报如下错误

Warning: Caught exception attempting to use SAX to load a SAX XMLReader
Warning: Exception was: java.lang.ClassNotFoundException: org/apache/xerces/parsers/SAXParser
Warning: I will print the stack trace then carry on using the default SAX parser
java.lang.ClassNotFoundException: org/apache/xerces/parsers/SAXParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)
at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
at org.dom4j.io.SAXReader.read(SAXReader.java:435)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.bjpowernode.drp.util.XmlConfigReader.<init>(XmlConfigReader.java:42)
at com.bjpowernode.drp.util.XmlConfigReader.getInstance(XmlConfigReader.java:76)
at com.bjpowernode.drp.util.ConnectionManager.getConnection(ConnectionManager.java:18)
at com.bjpowernode.drp.basedata.manager.ClientManager.findAllClient(ClientManager.java:400)
at com.bjpowernode.drp.basedata.manager.ClientManager.main(ClientManager.java:532)
org.dom4j.DocumentException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found Nested exception: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.bjpowernode.drp.util.XmlConfigReader.<init>(XmlConfigReader.java:42)
at com.bjpowernode.drp.util.XmlConfigReader.getInstance(XmlConfigReader.java:76)
at com.bjpowernode.drp.util.ConnectionManager.getConnection(ConnectionManager.java:18)
at com.bjpowernode.drp.basedata.manager.ClientManager.findAllClient(ClientManager.java:400)
at com.bjpowernode.drp.basedata.manager.ClientManager.main(ClientManager.java:532)
Nested exception:
java.lang.ClassNotFoundException: org/apache/xerces/parsers/SAXParser
at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:98)
at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
at org.dom4j.io.SAXReader.read(SAXReader.java:435)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.bjpowernode.drp.util.XmlConfigReader.<init>(XmlConfigReader.java:42)
at com.bjpowernode.drp.util.XmlConfigReader.getInstance(XmlConfigReader.java:76)
at com.bjpowernode.drp.util.ConnectionManager.getConnection(ConnectionManager.java:18)
at com.bjpowernode.drp.basedata.manager.ClientManager.findAllClient(ClientManager.java:400)
at com.bjpowernode.drp.basedata.manager.ClientManager.main(ClientManager.java:532)
Nested exception: java.lang.ClassNotFoundException: org/apache/xerces/parsers/SAXParser
at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:98)
at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)
at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)
at org.dom4j.io.SAXReader.read(SAXReader.java:435)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.bjpowernode.drp.util.XmlConfigReader.<init>(XmlConfigReader.java:42)
at com.bjpowernode.drp.util.XmlConfigReader.getInstance(XmlConfigReader.java:76)
at com.bjpowernode.drp.util.ConnectionManager.getConnection(ConnectionManager.java:18)
at com.bjpowernode.drp.basedata.manager.ClientManager.findAllClient(ClientManager.java:400)
at com.bjpowernode.drp.basedata.manager.ClientManager.main(ClientManager.java:532)
Exception in thread "main" java.lang.NullPointerException
at java.lang.Class.forN