문제

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);
    }

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.

Please help me.

Thanks Hp

도움이 되었습니까?

해결책

The JDOMException is (presumably) happening because the "testwww.net" server is sending a response body that is not XML. Change your program to print out the actual response stream instead of trying to parse it as XML. That should give you some clues as to what the underlying problem is. Even printing out the JDOMException stacktrace could be helpful ... assuming that you can get hold of that output.


If the problem is that you are running that code on some server and you can't get hold of debug info that your code writes to "system.out", the server logs or whatever, then you are in trouble. You will have to use your imagination to figure out some way around that roadblock.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top