Getting JDOMException on One Machine but the same

2019-09-08 04:43发布

问题:

I am hitting an xml and getting the response back in inputstream. This xml is on the remote server.

Whenever I am running my code on the server, it gives me JDOMException,but the same code, I am running on my local machine and hitting the same xml on remote server, it is running fine.

URL url = new URL("http://testwww.net/xml/android.xml");

InputStream stream = url.openStream();
try {
    SAXBuilder builder = new SAXBuilder(false);
    xmlDocument = builder.build(stream);
} catch (JDOMException e) {
    throw new Exception("unable to read android listing document", e);
}

Stack Trace is

org.jdom.input.JDOMParseException: Error on line 1: An invalid XML character (Unicode: 0x5c) was found in the public identifier. at org.jdom.input.SAXBuilder.build(SAXBuilder.java:468) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770) at com.cellularsouth.dao.appsdetails.GetAndroidApps.getCategoriesData(GetAndroidApps.java:42) at com.cellularsouth.discovercenter.appsdetails.web.AndroidApps.androidCategoryData(AndroidApps.java:28) at com.cellularsouth.servlets.discovercentercontroller.handleRequestInternal(discovercentercontroller.java:62) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) Caused by: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x5c) was found in the public identifier. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)

It gives me error on first line that but actually i cant see any problem here. XML is

--------------------------continue-----

I am not able to figure out what can be the problem here, that the same xml is running fine on one machine and not on other. There is no problem with the xml.

Please help me.

Thanks Hp

回答1:

I got the problem. The problem was that, my server was running in UNIX and my localhost is running on Windows. So, the xml was not properly encoded so Unix was not able to find some chacters and it was giving me Parsing error but they were rendering fine on Windows.