java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference

Appcelerator JIRA | Wilson Luu | 1 year ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    *Details:* Updating a record with Arrow Android SDK throws {{java.lang.NullPointerException}} in the {{onError}} callback. *Notes:* * To workaround this issue, you will need to replace lines 115 - 122 in {{API.java}} with the following: {code} JSONObject json = null; if(entity != null) { InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); } if(builder.length() != 0) { json = new JSONObject(builder.toString()); } } {code} * The workaround above incorporates the workaround from API-1196. *Steps to reproduce:* # Download and unzip MonkeyArr.zip; this is a *Android Studio* project # Open the project in Android Studio # Next, create an Arrow project and run the Arrow project locally # In the Android project, open {{MainActivity.java}} and change the following: ## Replace the API key in {{MonkeySdk.setAuthorization("71YFaz201s55+Mmvzh5G62sqo3tUwwbS")}}. ## If you are planning to launch against the stock emulator, replace {{10.0.3.2}} with {{10.0.2.2}}; otherwise, leave as-is. # Launch Android app to emualtor or Genymotion emulator # Press the {{Test}} button *Actual:* {{java.lang.NullPointerException}} is thrown to the {{onError}} callback: {code} 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #1 CREATE and READ test. 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #Finished test #1. 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr I/monkeyarr: onError 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.API.execute(API.java:115) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:430) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:421) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.lang.Thread.run(Thread.java:818) {code} *Expected:* {{java.lang.NullPointerException}} should not be thrown when updating a record.

    Appcelerator JIRA | 1 year ago | Wilson Luu
    java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference
  2. 0

    *Details:* Updating a record with Arrow Android SDK throws {{java.lang.NullPointerException}} in the {{onError}} callback. *Notes:* * To workaround this issue, you will need to replace lines 115 - 122 in {{API.java}} with the following: {code} JSONObject json = null; if(entity != null) { InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); } if(builder.length() != 0) { json = new JSONObject(builder.toString()); } } {code} * The workaround above incorporates the workaround from API-1196. *Steps to reproduce:* # Download and unzip MonkeyArr.zip; this is a *Android Studio* project # Open the project in Android Studio # Next, create an Arrow project and run the Arrow project locally # In the Android project, open {{MainActivity.java}} and change the following: ## Replace the API key in {{MonkeySdk.setAuthorization("71YFaz201s55+Mmvzh5G62sqo3tUwwbS")}}. ## If you are planning to launch against the stock emulator, replace {{10.0.3.2}} with {{10.0.2.2}}; otherwise, leave as-is. # Launch Android app to emualtor or Genymotion emulator # Press the {{Test}} button *Actual:* {{java.lang.NullPointerException}} is thrown to the {{onError}} callback: {code} 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #1 CREATE and READ test. 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #Finished test #1. 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr I/monkeyarr: onError 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.API.execute(API.java:115) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:430) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:421) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.lang.Thread.run(Thread.java:818) {code} *Expected:* {{java.lang.NullPointerException}} should not be thrown when updating a record.

    Appcelerator JIRA | 1 year ago | Wilson Luu
    java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference
  3. 0

    Getting a nullpointer exception when switching displayables in J2ME

    Stack Overflow | 6 years ago | Pallinder
    java.lang.NullPointerException: 0 at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 at com.sun.midp.chameleon.layers.SoftButtonLayer.soft1(), bci=37 at com.sun.midp.chameleon.layers.SoftButtonLayer.keyInput(), bci=36 at com.sun.midp.chameleon.CWindow.keyInput(), bci=38 at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=17 at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277 at com.sun.midp.events.EventQueue.run(), bci=179
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    J2ME (Java) - Null Pointer Exception caught in Display Class

    Stack Overflow | 6 years ago | Tom
    java.lang.NullPointerException: 0 at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 at com.sun.midp.chameleon.layers.SoftButtonLayer.soft1(), bci=37 at com.sun.midp.chameleon.layers.SoftButtonLayer.keyInput(), bci=36 at com.sun.midp.chameleon.CWindow.keyInput(), bci=38 at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=17 at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277 at com.sun.midp.events.EventQueue.run(), bci=179
  6. 0

    Cloud Foundry v2 in Grails

    Stack Overflow | 3 years ago | angelo087
    java.lang.NullPointerException: Cannot invoke method getAt() on null object

    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

      Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference

      at com.monkeysdk.API.execute()
    2. com.monkeysdk
      Testuser$9.doInBackground
      1. com.monkeysdk.API.execute(API.java:115)
      2. com.monkeysdk.Testuser$9.doInBackground(Testuser.java:430)
      3. com.monkeysdk.Testuser$9.doInBackground(Testuser.java:421)
      3 frames
    3. Android Platform
      AsyncTask$2.call
      1. android.os.AsyncTask$2.call(AsyncTask.java:288)
      1 frame
    4. Java RT
      FutureTask.run
      1. java.util.concurrent.FutureTask.run(FutureTask.java:237)
      1 frame
    5. Android Platform
      AsyncTask$SerialExecutor$1.run
      1. android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
      1 frame
    6. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      3. java.lang.Thread.run(Thread.java:818)
      3 frames