Hello Jason,

Replicated your environment here to try to to replicate the problem
you are experiencing.
Running JDK1.3.1_02
Running Tomcat 4.0.1
     Replaced the xerces.jar file located
     in the C:\tomcat-4.0.1\common\lib directory
     with xerces.jar from xerces 1.4.4

ran you example from both a command line and
from a sample servlet - and experienced no problem
in either scenario.

but will offer this up as the potential/probable error
you are experiencing

your variable sInput in your code of the servlet
is probably not what you think it is:
I say this because in my working servlet example, if
I set the value of sInput to the empty string ""
it will duplicate the stack trace you are experiencing.

My recomendation is
right before your line of code:
     BufferedReader bReader = new BufferedReader(new StringReader(sInput));

precede it with
     System.out.println("Sting to be parsed: " + sInput);

This should appear in the console and my guess that the variable
sInput is nothing more than the empty string.
yes this is shouldn't be the case if the code snippet you provide is
exactly what is in the servlet. but it cannot hurt to test to see that
what you are thinking is in sInput - actually is.

hope this helps

Dave Flanagan



J> --- Michael Glavassevich <[EMAIL PROTECTED]> wrote:
J> Michael,

J> Thanks for the input but actually I've verified that
J> Tomcat IS using xerces 1.44 - the same version that we
J> are both testing with on the command line.  Any other
J> thoughts?  If it's not encoding I can't imagine what
J> it could be - the xml is about as simple as you can
J> get and it's obviously well formed.  Thanks again for
J> the input.

J> -jason

>> 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
>> >
>>
J> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213
>> > )
>> >         at
>> >
>>
J> org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM
>> > LDocumentScanner.java:570)
>> >         at
>> >
>>
J> org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.endO
>> > fInput(XMLDocumentScanner.java:790)
>> >         at
>> >
>>
J> org.apache.xerces.framework.XMLDocumentScanner.endOfInput(XMLDocument
>> > Scanner.java:418)
>> >         at
>> >
>>
J> org.apache.xerces.validators.common.XMLValidator.sendEndOfInputNotifi
>> > cations(XMLValidator.java:712)
>> >         at
>> >
>>
J> org.apache.xerces.readers.DefaultEntityHandler.changeReaders(DefaultE
>> > ntityHandler.java:1031)
>> >         at
>> >
>>
J> org.apache.xerces.readers.XMLEntityReader.changeReaders(XMLEntityRead
>> > er.java:168)
>> >         at
>> >
>>
J> org.apache.xerces.readers.AbstractCharReader.changeReaders(AbstractCh
>> > arReader.java:150)
>> >         at
>> >
>>
J> org.apache.xerces.readers.AbstractCharReader.lookingAtChar(AbstractCh
>> > arReader.java:217)
>> >         at
>> >
>>
J> org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.disp
>> > atch(XMLDocumentScanner.java:686)
>> >         at
>> >
>>
J> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
>> > canner.java:381)
>> >         at
>> >
>>
J> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
>> >         at
>> >
>>
J> 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
>> >
>> >
>>
J> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> [EMAIL PROTECTED]
>> > For additional commands, e-mail:
>> [EMAIL PROTECTED]
>> >
>> >
>> 
>> -- 
>> --------------------
>> Michael Glavassevich
>> [EMAIL PROTECTED]
>> 
>>
J> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> [EMAIL PROTECTED]
>> For additional commands, e-mail:
>> [EMAIL PROTECTED]
>> 


J> __________________________________
J> Do you Yahoo!?
J> Yahoo! SiteBuilder - Free, easy-to-use web site design software
J> http://sitebuilder.yahoo.com

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



-- 
Best regards,
 Dave                            mailto:[EMAIL PROTECTED]



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

Reply via email to