Java.lang.IllegalArgumentException: protocol = http host = null

For this link http://bits.blogs.nytimes.com/2014/09/02/uber-banned-across-germany-by-frankfurt-court/?partner=rss&emc=rss this code doesn't work, but if I add another example: https://www.google.com everything is fine:

    URL url = new URL("http://bits.blogs.nytimes.com/2014/09/02/uber-banned-across-germany-by-frankfurt-court/?partner=rss&emc=rss");
        URLConnection uc;
    uc = url.openConnection();
    uc.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16");
    uc.addRequestProperty("referer", "http://www.facebook.com");
    uc.connect();     

    this.input = uc.getInputStream();

      

I am getting this exception:

java.lang.IllegalArgumentException: protocol = http host = null
    at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:170)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:926)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)
    at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2398)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1557)
    at UrlParser.<init>(UrlParser.java:48)
    at TikaParser.test_url_parser(TikaParser.java:186)
    at TikaParser.run(TikaParser.java:256)
    at java.lang.Thread.run(Thread.java:745)

      

what is wrong with my code?

+3


source to share


2 answers


I ran into the same exception when the url started with http:/

instead of http://

. eghttp:/www.example.com



It was in the method org.springframework.web.client.RestTemplate.exchange()

, so it's not exactly the same context, but possibly a similar problem.

+12


source


It looks like your proxy is not installed. Try to tweak it, then it should work.



For more information on proxy properties see this page .

0


source







All Articles