java.lang.IllegalArgumentException: protocol = http host = null
Für diesen link http://bits.blogs.nytimes.com/2014/09/02/uber-banned-across-germany-by-frankfurt-court/?partner=rss&emc=rss dieser code nicht funktioniert, aber wenn ich die anderen zum Beispiel: https://www.google.com alles ok ist:
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();
Bekomme ich diese 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)
was ist falsch an meinem code?
InformationsquelleAutor Goko Gorgiovski | 2014-09-03
Du musst angemeldet sein, um einen Kommentar abzugeben.
Dass ich auf diese gleiche Ausnahme, wenn die URL begann mit
http:/
statthttp://
. z.B.http:/www.example.com
Diese wurde in den
org.springframework.web.client.RestTemplate.exchange()
Methode, so dass es nicht ganz der gleiche Zusammenhang, aber vielleicht ein ähnliches Problem.InformationsquelleAutor wsams
Sieht aus wie Ihre proxy-host eingestellt ist. Versuchen Sie es, dann sollte es funktionieren.
Sehen auf dieser Seite für mehr Informationen zu den proxy-Eigenschaften.
versuchen Sie,- Dhttp.proxyHost=yourproxyhost über die Befehlszeile
InformationsquelleAutor Kai Sternad
Meist dieser Fehler auftreten, durch falsche url. Stellen Sie sicher, dass die Url, die Sie schlagen, ist richtig.Als wsams erwähnt, probiere die //in der url, ob es richtig ist oder nicht.
Richtige Muster ist http://localhost:8080
InformationsquelleAutor Dhirendra Gautam