My RCP plugin uses Xerces to parse XML files. To do this, I have Xerces jars in my classpath, and all looks fine.
But, if crimson.jar is put in the /lib/ext folder of the JRE (1.5.0_11), then when I use getTextContent() method of an instance of org.w3c.dom.Node interface, I realize that the crimson implementation was used rather than the Xerces one, because I get
java.lang.AbstractMethodError: org.apache.crimson.tree.ElementNode.getTextContent()Ljava/lang/String
The class name of the DocumentBuilderFactory which gets used is
org.apache.
crimson.jaxp.DocumentBuilderFactoryImpl
and if I simply take crimson.jar away from lib/ext folder of the JRE, then the class name of the DocumentBuilderFactory which is used is
org.apache.
xerces.jaxp.DocumentBuilderFactoryImpl
which I suppose is the Xerces implementation coming from the Xerces jars in my classpath. I need this one to be always used, regardless of whether crimson.jar is in the lib/ext folder of the JRE or not, because the implementation in crimson.jar causes the java.lang.AbstractMethodError. How should I do ?
Currently I'm doing
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl")
, but setting this system property has some side effects and I'm not sure it is the proper way.