Hi Jason,

This doesn't look like an encoding issue to me. Since the input source is
a Reader, the parser is already presented with a stream of characters, and
thus there's nothing to decode. I'm taking a wild guess, but I
think that the problem might be that the versions of Xerces that your
colleague is executing from the command line and Tomcat are different.
Specifically the stack trace indicates to me that the version of Tomcat
includes Xerces-J 1.4.4 or eariler. Perhaps that old version of the parser
had a bug in this area.

I hope that helps.

On Mon, 18 Aug 2003, Jason wrote:

> Hello,
>
> One of my colleagues has run into a bit of a problem
> with the following code:
>
>      try
>         {
>             DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
>             DocumentBuilder parser =
> factory.newDocumentBuilder();
>
>             String sInput = "<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><RequestType>DISCOVER_DATASOURCES</RequestType>";
>
>             BufferedReader bReader = new
> BufferedReader(new StringReader(sInput));
>             InputSource is = new InputSource(bReader);
>
>             Document doc = parser.parse(is);
>
>         }
>         catch (Throwable x)
>         {
>         }
>
> When he runs it from the command line everything works
> fine but embedded in a servlet running in Tomcat it
> generates the following error/stack trace.
>
> org.xml.sax.SAXParseException: The root element is
> required in a well-formed doc
> ument.
>         at
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213
> )
>         at
> org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM
> LDocumentScanner.java:570)
>         at
> org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.endO
> fInput(XMLDocumentScanner.java:790)
>         at
> org.apache.xerces.framework.XMLDocumentScanner.endOfInput(XMLDocument
> Scanner.java:418)
>         at
> org.apache.xerces.validators.common.XMLValidator.sendEndOfInputNotifi
> cations(XMLValidator.java:712)
>         at
> org.apache.xerces.readers.DefaultEntityHandler.changeReaders(DefaultE
> ntityHandler.java:1031)
>         at
> org.apache.xerces.readers.XMLEntityReader.changeReaders(XMLEntityRead
> er.java:168)
>         at
> org.apache.xerces.readers.AbstractCharReader.changeReaders(AbstractCh
> arReader.java:150)
>         at
> org.apache.xerces.readers.AbstractCharReader.lookingAtChar(AbstractCh
> arReader.java:217)
>         at
> org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.disp
> atch(XMLDocumentScanner.java:686)
>         at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
> canner.java:381)
>         at
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
>         at
> org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.
> java:195)
>
> I'm pretty sure this is an encoding issue but I'm not
> really sure how to help him solve it.  Any suggestions
> would be greatly appreciated.
>
> -jason
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-- 
--------------------
Michael Glavassevich
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to