• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem saving XML doc due to NoSuchMethodError...  RSS feed

Lee Wallen
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code that runs on one machine, but not on another. The JDK versions are nearly identical (one minor revision difference).

Version of JDK on machine where the code works:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_07-b02)

Version of JDK on machine where the code does not work:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_06-b01)

My assumption is that there is a classpath issue which causes the wrong version of a class to be loaded.

Does anyone know which JAR file I should be looking for, and/or does anyone recognize this error and know how to troubleshoot it?

I'm getting the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: org.w3c.dom.Document.getXmlStandalone()Z
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:373)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:127)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:94)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:663)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
at com.gettyimages.util.tools.ConfigUtil.convertXmlDocToString(ConfigUtil.java:186)

This is the method where the error is occuring:

* Converts an XML Document to a String.
* @param doc An XML Document.
* @return The content of the XML Document as a String.
public String convertXmlDocToString(Document doc) throws Exception {

TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty("omit-xml-declaration", "no");
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
transformer.transform(source, result);
return sw.getBuffer().toString();
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!