Re: Failure Parsing XML Document from Servlet
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! On Fri, Sep 30, 2011 at 1:31 AM, Thomas Broyer t.bro...@gmail.com wrote: 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. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/1h74ivOd75AJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Failure Parsing XML Document from Servlet
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. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/1h74ivOd75AJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Failure Parsing XML Document from Servlet
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 athinerc...@gmail.com 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. 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 supertagGriffinDashboard/supertag titlePubli 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:
Re: Failure Parsing XML Document from Servlet
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? -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Failure Parsing XML Document from Servlet
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.du...@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(); I hope it helps. Regards. Karim Duran 2011/9/29 AThinerCoin athinerc...@gmail.com 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. 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 supertagGriffinDashboard/supertag titlePubli 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
Re: Failure Parsing XML Document from Servlet
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* On Thu, Sep 29, 2011 at 2:41 PM, Laura Bickle bickle.la...@gmail.comwrote: 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.du...@gmail.comwrote: 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(); I hope it helps. Regards. Karim Duran 2011/9/29 AThinerCoin athinerc...@gmail.com 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. 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 supertagGriffinDashboard/supertag titlePubli 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
Re: Failure Parsing XML Document from Servlet
Hi Harpal, I've attached my xml file as graphs.xml. Please let me know if you can't see it. Thanks, Laura On Thu, Sep 29, 2011 at 12:13 PM, Harpal Grover harpal.gro...@gmail.comwrote: 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* On Thu, Sep 29, 2011 at 2:41 PM, Laura Bickle bickle.la...@gmail.comwrote: 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.du...@gmail.comwrote: 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(); I hope it helps. Regards. Karim Duran 2011/9/29 AThinerCoin athinerc...@gmail.com 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. 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 supertagGriffinDashboard/supertag titlePubli at
Re: Failure Parsing XML Document from Servlet
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. -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Failure Parsing XML Document from Servlet
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: titlePublishers -- Executive Summary for Friday, September 16th at 5:00pm/title Could you try removing the -- from the title and see if the document parses? On Thu, Sep 29, 2011 at 4:08 PM, Laura Bickle bickle.la...@gmail.comwrote: Hi Harpal, I've attached my xml file as graphs.xml. Please let me know if you can't see it. Thanks, Laura On Thu, Sep 29, 2011 at 12:13 PM, Harpal Grover harpal.gro...@gmail.comwrote: 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* On Thu, Sep 29, 2011 at 2:41 PM, Laura Bickle bickle.la...@gmail.comwrote: 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.du...@gmail.comwrote: 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(); I hope it helps. Regards. Karim Duran 2011/9/29 AThinerCoin athinerc...@gmail.com 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. 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
Re: Failure Parsing XML Document from Servlet
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 On Thu, Sep 29, 2011 at 1:19 PM, Harpal Grover harpal.gro...@gmail.comwrote: 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: titlePublishers -- Executive Summary for Friday, September 16th at 5:00pm/title Could you try removing the -- from the title and see if the document parses? On Thu, Sep 29, 2011 at 4:08 PM, Laura Bickle bickle.la...@gmail.comwrote: Hi Harpal, I've attached my xml file as graphs.xml. Please let me know if you can't see it. Thanks, Laura On Thu, Sep 29, 2011 at 12:13 PM, Harpal Grover harpal.gro...@gmail.comwrote: 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* On Thu, Sep 29, 2011 at 2:41 PM, Laura Bickle bickle.la...@gmail.comwrote: 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.du...@gmail.comwrote: 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(); I hope it helps. Regards. Karim Duran 2011/9/29 AThinerCoin athinerc...@gmail.com 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. 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:
Re: Failure Parsing XML Document from Servlet
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. * 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) On Thu, Sep 29, 2011 at 1:18 PM, Jeff Chimene jchim...@gmail.com mailto:jchim...@gmail.com wrote: 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. -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Failure Parsing XML Document from Servlet
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 On Thu, Sep 29, 2011 at 11:27 AM, Jeff Chimene jchim...@gmail.com wrote: 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? -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Failure Parsing XML Document from Servlet
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. 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 supertagGriffinDashboard/supertag titlePubli 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 -- 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-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.