SHORT SUMMARY: Classcast exception when using non-default JAXP parser INDICATORS: Exception : Exception in thread "main" java.lang.ClassCastException: oracle.xml.parser.v2.DTD cannot be cast to org.w3c.dom.Element at java.util.XMLUtils.load(XMLUtils.java:61) COUNTER INDICATORS: TRIGGERS: Use of non-default JAXP parser (oracle xml parser xmlparserv2.jar) in this case while making calls into java.util.XMLUtils.load method KNOWN WORKAROUND: Modify the parser used. PRESENT SINCE: N/A HOW TO VERIFY: Testcase presented in BugDB report. oracle xml parser "xmlparserv2.jar" should be present in CLASSPATH before running testcase. NOTES FOR SE: Logged on jdk 6u22 with linux x86 platform Fix is simple and suggested by submitter : == The error is in the line: Element propertiesElement = (Element)doc.getChildNodes().item(1); which is making an incorrect assumption about the in-memory structure of the parsed XML document. Instead, it should access the document element of the XML DOM tree using the standard DOM API getDocumentElement(): Element propertiesElement = doc.getDocumentElement(); ---- REGRESSION: No
|