views:

42

answers:

1

Hi , I'm having the code below..

         System.setProperty("http.proxyHost","176.6.129.25") ;
             System.setProperty("http.proxyPort", "8080") ;
Authenticator.setDefault(new MyAuthenticator());
                //http://deadlock.netbeans.org/hudson/api/xml
            *URL url = new URL("http://in8301782d:8080/api/xml");*
            Document dom = new SAXReader().read(url);
            for( Element job : (List<Element>)dom.getRootElement().elements("job")) {
                System.out.println(String.format("Name:%s\tStatus:%s",
                    job.elementText("name"), job.elementText("color")));
            }

This code is working if I replace with http://deadlock.netbeans.org/hudson/api/xml , but it is not working with http://in8301782d:8080/api/xml. Infact If I type the samething in browser it is working.. If I replace the hostname with Ip address also not working.

The exception I'm getting is below.

*With in8301782d (machine name)* :

xception in thread "main" org.dom4j.DocumentException: http://in8301782d:8080/api/xml Nested exception: http://in8301782d:8080/api/xml
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.dom4j.io.SAXReader.read(SAXReader.java:291)
    at com.sg.hudson.ci.Main.main(Main.java:140)
Nested exception: 
java.io.FileNotFoundException: http://in8301782d:8080/api/xml
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1243)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.dom4j.io.SAXReader.read(SAXReader.java:465)
    at org.dom4j.io.SAXReader.read(SAXReader.java:291)
    at com.sg.hudson.ci.Main.main(Main.java:140)

*With Ip (http://176.6.55.55:8080/api/xml):*

Exception in thread "main" org.dom4j.DocumentException: Server returned HTTP response code: 503 for URL: http://176.6.66.156:8080/api/xml Nested exception: Server returned HTTP response code: 503 for URL: http://176.6.66.156:8080/api/xml
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.dom4j.io.SAXReader.read(SAXReader.java:291)
    at com.sg.hudson.ci.Main.main(Main.java:140)
Nested exception: 
java.io.IOException: Server returned HTTP response code: 503 for URL: http://176.6.66.156:8080/api/xml
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.dom4j.io.SAXReader.read(SAXReader.java:465)
    at org.dom4j.io.SAXReader.read(SAXReader.java:291)
    at com.sg.hudson.ci.Main.main(Main.java:140)
+1  A: 

This doesn't appear to be a problem with your code.

In the first exception, SAX is telling you that it cannot find http://in8301782d:8080/api/xml - it cannot reach this URL. If the URL works in your browser, then perhaps the proxy setup is at fault.

In the second exception, SAX is reporting that the server is returning a non-success HTTP status code of 503, which (according to the HTTP specification) means:

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

Of course, the application sitting at this URL may be sending you a HTTP 503 for some non-standard reason as well.

matt b