Note that there are some explanatory texts on larger screens.

plurals
  1. POurl.openstream() or urlconnection.getinputstream() raise nullpointerexception on valid URL
    text
    copied!<p>For an android application I am trying to change an URL of an XML because of a new server, but the content is the same. I used to do this:</p> <pre><code>InputSource ins = new InputSource(rssUrl.openStream()); </code></pre> <p>This used to work and for a few days still does, while the old URL is available on on the old server. But when i change the URL of the XML I get an NullPointerException on the row above.</p> <p>I am sure rssUrl is not null, I printed the value of it an is just the working URL. I validated the XMl and the XML is valid, but this doesn't really matter because the problem is raised before the parsing starts.</p> <p>One of the things I tried was something like this:</p> <pre><code>Urlconnection urlConnection= rssUrl.openurlconnection(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); inputsource ins = new inputsource(in); </code></pre> <p>but this raised an nullpointerexception as well.</p> <p>I read some things <a href="https://groups.google.com/forum/#!msg/google-appengine/Scg13DQoFxw/Zxe8m_zBy0wJ" rel="nofollow noreferrer">about downgrading my Java to 6</a> (currently i am using 7). But i don't really feel like it and can't imagine why it would work.</p> <p><strong>edit:</strong> I tried downgrading to java se 6 but didn't work.</p> <p>Does anyone know how this error is possible and how to resolve it?</p> <p>stack:</p> <pre><code>12-28 22:14:53.635: W/System.err(6949): java.lang.NullPointerException 12-28 22:14:53.725: W/System.err(6949): at libcore.net.http.HttpConnection$Address.hashCode(HttpConnection.java:343) 12-28 22:14:53.725: W/System.err(6949): at java.util.HashMap.get(HashMap.java:298) 12-28 22:14:53.725: W/System.err(6949): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:67) 12-28 22:14:53.725: W/System.err(6949): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 12-28 22:14:53.725: W/System.err(6949): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308) 12-28 22:14:53.725: W/System.err(6949): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303) 12-28 22:14:53.735: W/System.err(6949): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282) 12-28 22:14:53.735: W/System.err(6949): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232) 12-28 22:14:53.735: W/System.err(6949): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273) 12-28 22:14:53.735: W/System.err(6949): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168) 12-28 22:14:53.735: W/System.err(6949): at java.net.URL.openStream(URL.java:462) 12-28 22:14:53.735: W/System.err(6949): at com.hera.ontdekdelft.StartUp$LoadData.doInBackground(StartUp.java:610) 12-28 22:14:53.735: W/System.err(6949): at com.hera.ontdekdelft.StartUp$LoadData.doInBackground(StartUp.java:1) 12-28 22:14:53.735: W/System.err(6949): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-28 22:14:53.735: W/System.err(6949): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-28 22:14:53.735: W/System.err(6949): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-28 22:14:53.735: W/System.err(6949): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-28 22:14:53.735: W/System.err(6949): at j.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-28 22:14:53.735: W/System.err(6949): at java.lang.Thread.run(Thread.java:856) ava.util </code></pre> <p><strong>Solution</strong></p> <p>Underscores in the URL caused android to fail. My solution was editing the url of the XML file so rssUrl.openstream() would work again. problem solved, thanks to <a href="https://stackoverflow.com/users/2358786/kiruwka">Kiruwka</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload