Chris Smith <> wrote in message news:<>...
> iksrazal wrote:
> > I'm getting this error from Xerces - and I can't seem to get the right
> > xerces jar in place to fix it:
> >
> > java.lang.NoSuchMethodError:
> > org.apache.xerces.util.NamespaceSupport.reset(Lorg/apache/xerces/util/SymbolTable;
>
> Your code doesn't call NamespaceSupport.reset... so you'll need to post
> the entire stack trace, so we can figure out where your code is really
> failing.
Thanks for the reply. Here's what I think is relevant - please let me
know if not.
----- Root Cause -----
java.lang.NoSuchMethodError:
org.apache.xerces.util.NamespaceSupport.reset(Lorg/apache/xerces/util/SymbolTable

V
at org.apache.xml.serialize.XMLSerializer.reset(XMLSe rializer.java:1424)
at org.apache.xml.serialize.BaseMarkupSerializer.setO utputCharStream(BaseMarkupSerializer.java:335)
at org.apache.xml.serialize.XMLSerializer.<init>(XMLS erializer.java:199)
at com.infoseg.mr.security.XMLHelper.getXml(XMLHelper .java:162)
Here's the same code with line numbers:
156 public static final String getXml(Document document) throws
XMLHelperException
157 {
158 try
159 {
160 OutputFormat format = new OutputFormat(document);
161 StringWriter stringOut = new StringWriter();
162 XMLSerializer serial = new XMLSerializer( stringOut,
format );
163 serial.asDOMSerializer();
164 serial.serialize(document.getDocumentElement());
165 return stringOut.toString();
166 }
167 catch(Exception e)
168 {
169 throw new XMLHelperException("XML Document to String
Err", e);
170 }
171 }
The way I read the stacktrace is the first line with my code is 162
above.
I was able to fix the problem with JAXP code - although I'd like to
fix this using xerces if possible.
public static final String getXml(Document document) throws
XMLHelperException
{
try
{
// Create source and result objects
Source source = new DOMSource(document);
StringWriter out = new StringWriter();
Result result = new StreamResult(out);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.transform(source, result);
return out.toString();
}
}
iksrazal