java.lang.NullPointerException

Appcelerator JIRA | Daniel Cameron | 6 years ago
  1. 0

    {html}<div><p>HTTPClient crashes when the HTTP Response sent is 0 bytes long.</p> <h2>Versions:</h2> <ul> <li>Titanium Mobile SDK 1.5.1</li> <li>Android SDK r9</li> </ul> <h2>Debugging Trace:</h2> <pre> [TRACE] D/TiHttpClient( 1727): (kroll$1) [96,2260] Setting ready state to 1 [TRACE] W/TiTabActivity( 1727): (main) [94,2354] Notifying TiTabGroup, activity is created [TRACE] D/qemud ( 38): fdhandler_accept_event: accepting on fd 10 [TRACE] D/qemud ( 38): created client 0x2c938 listening on fd 15 [TRACE] D/qemud ( 38): client_fd_receive: attempting registration for service 'sensors' [TRACE] D/qemud ( 38): client_fd_receive: -&gt; received channel id 20 [TRACE] D/qemud ( 38): client_registration: registration succeeded for client 20 [TRACE] D/qemud ( 38): fdhandler_event: disconnect on fd 15 [TRACE] I/ActivityManager( 60): Displayed activity unittest.httpclient/ti.modules.titanium.ui.TiTabActivity: 2466 ms (total 2466 ms) [TRACE] D/dalvikvm( 1727): GC_FOR_MALLOC freed 3458 objects / 210168 bytes in 150ms [TRACE] D/TiHttpClient( 1727): (TiHttpClient-1) [4134,6488] Setting ready state to 2 [TRACE] D/TiHttpClient( 1727): (TiHttpClient-1) [2,6490] Setting ready state to 3 [TRACE] E/TiHttpClient( 1727): (TiHttpClient-1) [10,6500] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1727): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:316) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:252) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:165) [TRACE] E/TiHttpClient( 1727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) [TRACE] E/TiHttpClient( 1727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:997) [TRACE] E/TiHttpClient( 1727): at java.lang.Thread.run(Thread.java:1096) [TRACE] I/TiHttpClient( 1727): (TiHttpClient-1) [28,6528] Sending error java.lang.NullPointerException [TRACE] W/TiConvert( 1727): (kroll$1) [28,6556] Unsupported type class ti.modules.titanium.network.HTTPClientProxy [ERROR] [3,6559] HTTPClient error={"error":"java.lang.NullPointerException"} </pre> <h2>Repo steps:</h2> <ul> <li>Create New Project</li> <li>Add the following to app.js:</li> </ul> <pre> <code>var xhr = Titanium.Network.createHTTPClient(); xhr.onerror = function (e) { Ti.API.error('HTTPClient error='+JSON.stringify(e)); }; xhr.onload = function () { Ti.API.info('status=' + xhr.status); Ti.API.info('responseText=' + xhr.responseText); Ti.API.info('responseText=' + xhr.responseText); }; xhr.open('GET', 'http://www.danielcameron.com/m/empty.html'); // can replace with any HTTP request for a 0 byte file xhr.send();</code> </pre></div>{html}

    Appcelerator JIRA | 6 years ago | Daniel Cameron
    java.lang.NullPointerException
  2. 0

    {html}<div><p>HTTPClient crashes when the HTTP Response sent is 0 bytes long.</p> <h2>Versions:</h2> <ul> <li>Titanium Mobile SDK 1.5.1</li> <li>Android SDK r9</li> </ul> <h2>Debugging Trace:</h2> <pre> [TRACE] D/TiHttpClient( 1727): (kroll$1) [96,2260] Setting ready state to 1 [TRACE] W/TiTabActivity( 1727): (main) [94,2354] Notifying TiTabGroup, activity is created [TRACE] D/qemud ( 38): fdhandler_accept_event: accepting on fd 10 [TRACE] D/qemud ( 38): created client 0x2c938 listening on fd 15 [TRACE] D/qemud ( 38): client_fd_receive: attempting registration for service 'sensors' [TRACE] D/qemud ( 38): client_fd_receive: -&gt; received channel id 20 [TRACE] D/qemud ( 38): client_registration: registration succeeded for client 20 [TRACE] D/qemud ( 38): fdhandler_event: disconnect on fd 15 [TRACE] I/ActivityManager( 60): Displayed activity unittest.httpclient/ti.modules.titanium.ui.TiTabActivity: 2466 ms (total 2466 ms) [TRACE] D/dalvikvm( 1727): GC_FOR_MALLOC freed 3458 objects / 210168 bytes in 150ms [TRACE] D/TiHttpClient( 1727): (TiHttpClient-1) [4134,6488] Setting ready state to 2 [TRACE] D/TiHttpClient( 1727): (TiHttpClient-1) [2,6490] Setting ready state to 3 [TRACE] E/TiHttpClient( 1727): (TiHttpClient-1) [10,6500] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1727): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:316) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:252) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:165) [TRACE] E/TiHttpClient( 1727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) [TRACE] E/TiHttpClient( 1727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:997) [TRACE] E/TiHttpClient( 1727): at java.lang.Thread.run(Thread.java:1096) [TRACE] I/TiHttpClient( 1727): (TiHttpClient-1) [28,6528] Sending error java.lang.NullPointerException [TRACE] W/TiConvert( 1727): (kroll$1) [28,6556] Unsupported type class ti.modules.titanium.network.HTTPClientProxy [ERROR] [3,6559] HTTPClient error={"error":"java.lang.NullPointerException"} </pre> <h2>Repo steps:</h2> <ul> <li>Create New Project</li> <li>Add the following to app.js:</li> </ul> <pre> <code>var xhr = Titanium.Network.createHTTPClient(); xhr.onerror = function (e) { Ti.API.error('HTTPClient error='+JSON.stringify(e)); }; xhr.onload = function () { Ti.API.info('status=' + xhr.status); Ti.API.info('responseText=' + xhr.responseText); Ti.API.info('responseText=' + xhr.responseText); }; xhr.open('GET', 'http://www.danielcameron.com/m/empty.html'); // can replace with any HTTP request for a 0 byte file xhr.send();</code> </pre></div>{html}

    Appcelerator JIRA | 6 years ago | Daniel Cameron
    java.lang.NullPointerException
  3. 0

    {html}<div><p>I have a page that returns a 200 response, but nothing in the body.<br></p> <pre> <code>var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() {Ti.API.info('I am in utf-8 onload for POST');}; xhr.onerror = function() {Ti.API.info('I am in utf-8 error for POST');}; xhr.open("POST","http://mywebsite.com/script.cfm"); xhr.send({"a":"hi", "b":"there"});</code> </pre> If the sript I post to doesn't return a body, only a 200, then the NPE happens. If I change the script to return any text at all the NPE is avoided. <p>The resulting log of the NPE looks like:<br></p> <pre> <code>[TRACE] E/TiUIView( 1729): (main) [5383,101697] TAP, TAP, TAP on [Ti.UI.Button] [TRACE] D/TiHttpClient( 1729): (kroll$3) [10,101707] Setting ready state to 1 [TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 12700 objects / 611088 bytes in 124ms [TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 1967 objects / 297312 bytes in 369ms [TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [2521,104228] Setting ready state to 2 [TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [0,104228] Setting ready state to 3 [TRACE] E/TiHttpClient( 1729): (TiHttpClient-2) [2,104230] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1729): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:321) [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:257) [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:166) [TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) [TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1010) [TRACE] E/TiHttpClient( 1729): at java.lang.Thread.run(Thread.java:1096) [TRACE] I/TiHttpClient( 1729): (TiHttpClient-2) [3,104233] Sending error java.lang.NullPointerException</code> </pre></div>{html}

    Appcelerator JIRA | 6 years ago | Anthony Webb
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    {html}<div><p>I have a page that returns a 200 response, but nothing in the body.<br></p> <pre> <code>var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() {Ti.API.info('I am in utf-8 onload for POST');}; xhr.onerror = function() {Ti.API.info('I am in utf-8 error for POST');}; xhr.open("POST","http://mywebsite.com/script.cfm"); xhr.send({"a":"hi", "b":"there"});</code> </pre> If the sript I post to doesn't return a body, only a 200, then the NPE happens. If I change the script to return any text at all the NPE is avoided. <p>The resulting log of the NPE looks like:<br></p> <pre> <code>[TRACE] E/TiUIView( 1729): (main) [5383,101697] TAP, TAP, TAP on [Ti.UI.Button] [TRACE] D/TiHttpClient( 1729): (kroll$3) [10,101707] Setting ready state to 1 [TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 12700 objects / 611088 bytes in 124ms [TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 1967 objects / 297312 bytes in 369ms [TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [2521,104228] Setting ready state to 2 [TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [0,104228] Setting ready state to 3 [TRACE] E/TiHttpClient( 1729): (TiHttpClient-2) [2,104230] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1729): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:321) [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:257) [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:166) [TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) [TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) [TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1010) [TRACE] E/TiHttpClient( 1729): at java.lang.Thread.run(Thread.java:1096) [TRACE] I/TiHttpClient( 1729): (TiHttpClient-2) [3,104233] Sending error java.lang.NullPointerException</code> </pre></div>{html}

    Appcelerator JIRA | 6 years ago | Anthony Webb
    java.lang.NullPointerException
  6. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData()
    2. ti.modules.titanium
      TiHTTPClient$LocalResponseHandler.handleResponse
      1. ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:316)
      2. ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:252)
      3. ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:165)
      3 frames
    3. Apache HttpClient
      AbstractHttpClient.execute
      1. org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
      2. org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
      2 frames
    4. ti.modules.titanium
      TiHTTPClient$ClientRunnable.run
      1. ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:997)
      1 frame
    5. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:1096)
      1 frame