Failure Parsing XML Document from Servlet

890 views
Skip to first unread message

AThinerCoin

unread,
Sep 29, 2011, 1:01:48 AM9/29/11
to Google Web Toolkit
I'd like to pass an xml file to my gwt client. I created another
servlet that fetches it from the local file system and returns the xml
file when I call its url.

If I go to the url from my browser, it looks fine. If I fetch the url
from curl, it uses the >< kind of format. If I fetch the url
from my gwt client, I get different results and error messages in
development versus production mode.

If I archive the xml file directly into the war, my program works
perfectly.

I'm pretty sure it's not a GWT issue, but I'm not sure where else to
turn. Any guidance would be appreciated.

In development, it looks like I don't get a result at all and my error
is:
(XMLParserImplSafari.java:38) 2011-09-28 18:13:24,828 [FATAL] Uncaught
Exception:
com.google.gwt.xml.client.impl.DOMParseException: Failed to parse:
error on line 1 at column 1: Extra content at the end of the document
at
com.google.gwt.xml.client.impl.XMLParserImplSafari.throwDOMParseException(XMLParserImplSafari.java:
38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
167)
at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:
326)
at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
207)
at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
132)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
561)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
269)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:
91)
at
com.google.gwt.xml.client.impl.XMLParserImplSafari.parseImpl(XMLParserImplSafari.java)
at
com.google.gwt.xml.client.impl.XMLParserImpl.parse(XMLParserImpl.java:
278)
at com.google.gwt.xml.client.XMLParser.parse(XMLParser.java:47)

In production, I get what looks like the right result back (based on
Log statements), and my error is:
com.google.gwt.xml.client.impl.DOMParseException: Failed to parse: <?
xml version="1.0" encoding="UTF-8"?><stuff>
<supertag>GriffinDashboard</supertag> <title>Publi
at
Unknown.java_lang_Throwable_fillInStackTrace__Ljava_lang_Throwable_2(Unknown
Source)
at
Unknown.com_google_gwt_xml_client_DOMException_DOMException__SLjava_lang_String_2V(Unknown
Source)
at
Unknown.com_google_gwt_xml_client_impl_DOMParseException_DOMParseException__Ljava_lang_String_2Ljava_lang_Throwable_2V(Unknown
Source)
at Unknown.com_google_gwt_xml_client_impl_XMLParserImpl_
$parse__Lcom_google_gwt_xml_client_impl_XMLParserImpl_2Ljava_lang_String_2Lcom_google_gwt_xml_client_Document_2(Unknown
Source)
at Unknown.com_atti_aas_griffin_dashboard_client_Config_
$parseChart__Lcom_atti_aas_griffin_dashboard_client_Config_2Ljava_lang_String_2V(Unknown
Source)
at
Unknown.com_atti_aas_griffin_dashboard_client_Config_Config__Ljava_lang_String_2V(Unknown
Source)
at Unknown.com_atti_aas_griffin_dashboard_client_GWTClient
$1_onResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_Response_2V(Unknown
Source)
at Unknown.com_google_gwt_http_client_Request_
$fireOnResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_RequestCallback_2V(Unknown
Source)
at Unknown.com_google_gwt_http_client_RequestBuilder
$1_onReadyStateChange__Lcom_google_gwt_xhr_client_XMLHttpRequest_2V(Unknown
Source)
at Unknown.anonymous(Unknown Source)
at
Unknown.com_google_gwt_core_client_impl_Impl_apply__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2(Unknown
Source)
at
Unknown.com_google_gwt_core_client_impl_Impl_entry0__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2(Unknown
Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
Caused by: com.google.gwt.core.client.JavaScriptException: (Error):
XML Parsing Error: not well-formed

karim duran

unread,
Sep 29, 2011, 9:02:27 AM9/29/11
to google-we...@googlegroups.com
Hi AThinerCoin,

I agree with you : "I'm pretty sure it's not a GWT issue"...

1) if you want to serve XML from your servlet, why do you need to parse it ????? Simply serve it. That's all
2) did you set correct content type from your sevlet ? -> response.setContentType("text/xml");
3) did you close your stream with the close() method of the OutPutStream ?
4) your GWT client receive a raw XML stream. What do you do with it ?

I hope it helps.

Regards.

Karim Duran

2011/9/29 AThinerCoin <athin...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Jeff Chimene

unread,
Sep 29, 2011, 2:27:10 PM9/29/11
to google-we...@googlegroups.com
On 09/28/2011 10:01 PM, AThinerCoin wrote:
> I'd like to pass an xml file to my gwt client. I created another
> servlet that fetches it from the local file system and returns the xml
> file when I call its url.
>
> If I go to the url from my browser, it looks fine. If I fetch the url
> from curl, it uses the &gt;&lt; kind of format. If I fetch the url
> from my gwt client, I get different results and error messages in
> development versus production mode.
>
> If I archive the xml file directly into the war, my program works
> perfectly.
>
> I'm pretty sure it's not a GWT issue, but I'm not sure where else to
> turn. Any guidance would be appreciated.
1) Try another client, since parsing is handled by the browser. That may
provide a different set of clues;
2) What does xmllint say about this document?

Laura Bickle

unread,
Sep 29, 2011, 2:41:28 PM9/29/11
to google-we...@googlegroups.com
Hi Karim,

Thanks for your suggestions, but I'm still getting errors.  I've included the relevant code snippets below.  I may be missing something you've mentioned.

Thanks again,
Laura

On Thu, Sep 29, 2011 at 6:02 AM, karim duran <karim...@gmail.com> wrote:
Hi AThinerCoin,

I agree with you : "I'm pretty sure it's not a GWT issue"...

1) if you want to serve XML from your servlet, why do you need to parse it ????? Simply serve it. That's all

The servlet that serves the xml file just serves the xml file.  The errors come from the GWT Client that requests and tries to use the xml file. 
 
2) did you set correct content type from your sevlet ? -> response.setContentType("text/xml");
Yes, the response type is text/xml.
 
3) did you close your stream with the close() method of the OutPutStream ?
I thought I did, but I may be missing something.  Servlet code snippet:

        String record = "";
        try{
            BufferedReader reader = new BufferedReader(new FileReader(filename));
            String line;
            while ((line = reader.readLine()) != null){
                record += line;
            }
            reader.close();
            XMLWriter writer = new XMLWriter(out);
            writer.write(record);
            writer.close();
        }catch (Exception e){
            System.err.format("Exception occurred trying to read '%s'.", filename);
            e.printStackTrace();
        }

 
4) your GWT client receive a raw XML stream. What do you do with it ?

import com.google.gwt.xml.client.XMLParser;

...

        Document dom = XMLParser.parse(xmlString); // This is the line that gives me errors.
        Element docEle = dom.getDocumentElement();
 

Harpal Grover

unread,
Sep 29, 2011, 3:13:35 PM9/29/11
to google-we...@googlegroups.com
Could you attach the generated XML document if possible, or do you know if it's well-formatted and compliant to the xml spec?

-- 
Harpal Grover
President
Harpal Grover Consulting Inc

Laura Bickle

unread,
Sep 29, 2011, 3:41:13 PM9/29/11
to google-we...@googlegroups.com
Hi Jeff,

I tried using curl.  It showed my angle brackets as &gt; and &lt; but I don't think that matters to my code because it looks right in the print statements.

I don't think my xml is actually malformed because, when I include the xml file directly in the archive, my gwt client parses it without problem.

Thank you for suggesting xmllint.  I hadn't heard of it before.  I'll try it and see if it provides any clues.

Thanks again for your help

Laura Bickle

unread,
Sep 29, 2011, 4:08:45 PM9/29/11
to google-we...@googlegroups.com
Hi Harpal,

I've attached my xml file as graphs.xml.  Please let me know if you can't see it.

Thanks,
Laura
graphs.xml

Jeff Chimene

unread,
Sep 29, 2011, 4:18:56 PM9/29/11
to google-we...@googlegroups.com
On 09/29/2011 12:41 PM, Laura Bickle wrote:
> Hi Jeff,
>
> I tried using curl. It showed my angle brackets as &gt; and &lt; but I
> don't think that matters to my code because it looks right in the print
> statements.
>
> I don't think my xml is actually malformed because, when I include the
> xml file directly in the archive, my gwt client parses it without problem.
>
> Thank you for suggesting xmllint. I hadn't heard of it before. I'll
> try it and see if it provides any clues.
>
> Thanks again for your help

xmllint doesn't complain, and neither does Emacs' nXML mode.

So, the problem is the way the data are sent to the client from the server.

Someone else asked, maybe I missed the answer: what is the document's
MIME type?

Also, did you try another browser? For example, I noticed that IE had
problems with one of my documents when FF did not.

Harpal Grover

unread,
Sep 29, 2011, 4:19:58 PM9/29/11
to google-we...@googlegroups.com
Thanks Laura. The xml definitely doesn't seem to have any errors. However, this line in the XML document looks a little suspicious when it comes to parsing it:

<title>Publishers -- Executive Summary for Friday, September 16th at 5:00pm</title>

Could you try removing the "--" from the title and see if the document parses?

Laura Bickle

unread,
Sep 29, 2011, 4:39:40 PM9/29/11
to google-we...@googlegroups.com
Hi Jeff,

I set the content type like so:  response.setContentType("text/xml");

I think MIME is a superset of content type.  I don't explicitly set any other MIME things.  How do I look up the MIME type of a file?

My previous errors are from firefox.  Per your suggestion, I tried using safari and chrome instead and they each gave me this error.  The first line is the result of requesting the xml file.  The second line comes from trying to parse it.

(-:-) 2011-09-29 13:32:28,825 [DEBUG] result:<?xml version="1.0" encoding="UTF-8"?><stuff> <supertag>GriffinDashboard</supertag> <title>Publishers -- Executive Summary for Friday, September 16th at 5:00pm</title> <metrics> <metric> <title>Total Impressions</title> <xmlname>1</xmlname> <trend>STRONG_UP</trend> <change>70</change> <value>50</value> <color>#538026</color></metric> <metric> <title>Total Clicks</title> <xmlname>2</xmlname> <trend>UP</trend> <change>20</change> <value>60</value> <color>#268080</color></metric> <metric> <title>Total Requests</title> <xmlname>3</xmlname> <trend>NO_CHANGE</trend> <change>3</change> <value>70</value> <color>#532680</color></metric> <metric> <title>Fill Rate</title> <xmlname>4</xmlname> <trend>DOWN</trend> <change>-20</change> <value>71%</value> <color>#802626</color></metric> </metrics> <charts> <chart> <title>Impressions</title> <xmlname>1</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>publisher a</title> <color>orange</color> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> <graph> <title>publisher b</title> <color>yellow</color> <xmlname>xmlname</xmlname> <datapoint x="0" y=".456"/> <datapoint x="1" y=".123"/> <datapoint x="2" y=".234"/> <datapoint x="3" y=".345"/> <datapoint x="4" y=".456"/> <datapoint x="5" y=".567"/> <datapoint x="6" y=".256"/> <datapoint x="7" y=".345"/> <datapoint x="8" y=".542"/> <datapoint x="9" y=".123"/> <datapoint x="10" y=".278"/> <datapoint x="11" y=".456"/> <datapoint x="12" y=".421"/> <datapoint x="13" y=".456"/> <datapoint x="14" y=".421"/> <datapoint x="15" y=".456"/> <datapoint x="16" y=".421"/> <datapoint x="17" y=".456"/> <datapoint x="18" y=".123"/> <datapoint x="19" y=".456"/> <datapoint x="20" y=".421"/> <datapoint x="21" y=".456"/> <datapoint x="22" y=".421"/> <datapoint x="23" y=".456"/> <datapoint x="24" y=".421"/> </graph> </graphs> <color>#808026</color></chart> <chart> <title>Revenue</title> <xmlname>2</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#268026</color></chart> <chart> <title>Impressions</title> <xmlname>3</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#268080</color></chart> <chart> <title>CPM</title> <xmlname>4</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#262680</color></chart> <chart> <title>Clickthroughs</title> <xmlname>5</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#802680</color></chart> <chart> <title>Clickthrough Ratio</title> <xmlname>6</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#802626</color></chart> <chart> <title>Requests</title> <xmlname>7</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#808026</color></chart> <chart> <title>Sellthrough Rate</title> <xmlname>8</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#268026</color></chart> <chart> <title>Unfilled Requests</title> <xmlname>9</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#268080</color></chart> <chart> <title>Undelivered Impressions</title> <xmlname>10</xmlname> <xlabels> <xlabel pos="2" name="2:00pm"/> <xlabel pos="6" name="6:00pm"/> <xlabel pos="10" name="10:00pm"/> <xlabel pos="14" name="2:00am"/> <xlabel pos="18" name="6:00am"/> <xlabel pos="22" name="10:00am"/> </xlabels> <ylabels> <ylabel pos="0" name="60%"/> <ylabel pos=".25" name="70%"/> <ylabel pos=".5" name="80%"/> <ylabel pos=".75" name="90%"/> <ylabel pos="1" name="100%"/> </ylabels> <graphs> <graph> <title>a</title> <xmlname>xmlname</xmlname> <datapoint x="0" y=".123"/> <datapoint x="1" y=".234"/> <datapoint x="2" y=".345"/> <datapoint x="3" y=".456"/> <datapoint x="4" y=".567"/> <datapoint x="5" y=".256"/> <datapoint x="6" y=".345"/> <datapoint x="7" y=".542"/> <datapoint x="8" y=".123"/> <datapoint x="9" y=".278"/> <datapoint x="10" y=".456"/> <datapoint x="11" y=".421"/> <datapoint x="12" y=".456"/> <datapoint x="13" y=".421"/> <datapoint x="14" y=".456"/> <datapoint x="15" y=".421"/> <datapoint x="16" y=".456"/> <datapoint x="17" y=".123"/> <datapoint x="18" y=".456"/> <datapoint x="19" y=".421"/> <datapoint x="20" y=".456"/> <datapoint x="21" y=".421"/> <datapoint x="22" y=".456"/> <datapoint x="23" y=".421"/> <datapoint x="24" y=".456"/> </graph> </graphs> <color>#262680</color></chart> </charts></stuff>
(-:-) 2011-09-29 13:32:28,838 [FATAL] Uncaught Exception:
com.google.gwt.xml.client.impl.DOMParseException: Failed to parse: error on line 1 at column 1: Document is empty
    at Unknown.java_lang_Throwable_fillInStackTrace__Ljava_lang_Throwable_2(Unknown Source)
    at Unknown.com_google_gwt_xml_client_DOMException_DOMException__SLjava_lang_String_2V(Unknown Source)
    at Unknown.com_google_gwt_xml_client_impl_DOMParseException_DOMParseException__Ljava_lang_String_2V(Unknown Source)
    at Unknown.com_google_gwt_xml_client_impl_XMLParserImplSafari_throwDOMParseException__Ljava_lang_String_2V(Unknown Source)
    at Unknown.com_google_gwt_xml_client_impl_XMLParserImplSafari_$parseImpl__Lcom_google_gwt_xml_client_impl_XMLParserImplSafari_2Ljava_lang_String_2Lcom_google_gwt_core_client_JavaScriptObject_2(Unknown Source)
    at Unknown.com_google_gwt_xml_client_impl_XMLParserImpl_$parse__Lcom_google_gwt_xml_client_impl_XMLParserImpl_2Ljava_lang_String_2Lcom_google_gwt_xml_client_Document_2(Unknown Source)
    at Unknown.com_atti_aas_griffin_dashboard_client_Config_$parseChart__Lcom_atti_aas_griffin_dashboard_client_Config_2Ljava_lang_String_2V(Unknown Source)



--

Laura Bickle

unread,
Sep 29, 2011, 4:44:21 PM9/29/11
to google-we...@googlegroups.com
Hi Harpal,

Thanks for your suggestion.  I tried removing the dashes.  The log statements updated to reflect the change, but I still get the same error.

Laura

Jeff Chimene

unread,
Sep 29, 2011, 5:17:19 PM9/29/11
to google-we...@googlegroups.com
On 09/29/2011 01:39 PM, Laura Bickle wrote:
> Hi Jeff,
>
> I set the content type like so: response.setContentType("text/xml");
>
> I think MIME is a superset of content type. I don't explicitly set any
> other MIME things. How do I look up the MIME type of a file?

http://en.wikipedia.org/wiki/XML_and_MIME

> My previous errors are from firefox. Per your suggestion, I tried using
> safari and chrome instead and they each gave me this error. The first
> line is the result of requesting the xml file. The second line comes
> from trying to parse it.
>

(document snipped)

> (-:-) 2011-09-29 13:32:28,838 [FATAL] Uncaught Exception:

> *com.google.gwt.xml.client.impl.DOMParseException: Failed to parse:


> error on line 1 at column 1: Document is empty

Well, that's a clue ;-

I tried the following:

final String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><stuff> ..";
final Document doc = XMLParser.parse(s);

It had no problems.

The only differences:
1) I escaped the quote characters;
2) I removed the line breaks (^J) in your file to convert it to a string.

I'd investigate the line breaks, and possibly some garbage at the end of
the file that gets sent to the host.

Also, depending on your server, you might be sending a byte order mark
to the client and not realizing it.

> *

Thomas Broyer

unread,
Sep 30, 2011, 4:31:31 AM9/30/11
to google-we...@googlegroups.com


On Thursday, September 29, 2011 10:39:40 PM UTC+2, Laura Bickle wrote:
Hi Jeff,

I set the content type like so:  response.setContentType("text/xml");

I think MIME is a superset of content type.  I don't explicitly set any other MIME things.  How do I look up the MIME type of a file?

My previous errors are from firefox.  Per your suggestion, I tried using safari and chrome instead and they each gave me this error.  The first line is the result of requesting the xml file.  The second line comes from trying to parse it.

(-:-) 2011-09-29 13:32:28,825 [DEBUG] result:<?xml version="1.0" encoding="UTF-8"?><stuff>

IIRC, some browsers (can't remember which ones) choke on the XMLDecl when it specifies an encoding; because you're parsing a String, which is a stream of characters, and encodings only applies to streams of bytes (to actually turn the bytes into characters).
Try trimming the XMLDecl from your XML before giving it to XMLParser.parse().
Something like (untested):
if (xml.substring(0, 5).equalsIgnoreCase("<?xml")) {
   xml = xml.substring(xml.indexOf("?>") + 2);
}

Best would of course be to emit the encoding in the Content-Type HTTP header (application/xml; charset=UTF-8) and not send the XMLDecl at all.

Laura Bickle

unread,
Oct 7, 2011, 12:57:22 AM10/7/11
to google-we...@googlegroups.com
The problem was that I was using an XMLWriter instead of a StringBuilder and a normal file writer.  XMLWriter was adding additional and invalid characters.

Thanks everybody for taking the time to help me!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
Reply all
Reply to author
Forward
0 new messages