java.lang.NullPointerException

Appcelerator JIRA | Tommy Leung | 4 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    *Problem* Reading a null value from a resultset causes a NullPointer Exception *Test case* {code:javascript} var win = Ti.UI.createWindow(); win.open(); var db = Ti.Database.open('testDB'); db.execute('CREATE TABLE IF NOT EXISTS test(name TEXT, captured INTEGERL);'); db.execute('INSERT INTO test (name, captured) VALUES (?,?)', "111", 222); db.execute('INSERT INTO test (name, captured) VALUES (?,?)', null, null); var results = db.execute('SELECT name, captured FROM test'); while (results.isValidRow()) { var name = results.field(0); var captured = results.fieldByName('captured'); Ti.API.info(name + ' ' + captured); results.next(); } results.close(); db.close(); {code} *Log* {code} E/TiResultSet(32758): (KrollRuntimeThread) [4,1124] Exception getting value for column 7: null E/TiResultSet(32758): java.lang.NullPointerException E/TiResultSet(32758): at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:58) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.getInputStream(TiBlob.java:319) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.guessContentTypeFromStream(TiBlob.java:193) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.loadBitmapInfo(TiBlob.java:209) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.blobFromData(TiBlob.java:182) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.blobFromData(TiBlob.java:165) E/TiResultSet(32758): at ti.modules.titanium.database.TiResultSetProxy.internalGetField(TiResultSetProxy.java:113) E/TiResultSet(32758): at ti.modules.titanium.database.TiResultSetProxy.internalGetField(TiResultSetProxy.java:92) E/TiResultSet(32758): at ti.modules.titanium.database.TiResultSetProxy.field(TiResultSetProxy.java:64) E/TiResultSet(32758): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) E/TiResultSet(32758): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:159) E/TiResultSet(32758): at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289) E/TiResultSet(32758): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:185) E/TiResultSet(32758): at android.os.Handler.dispatchMessage(Handler.java:95) E/TiResultSet(32758): at android.os.Looper.loop(Looper.java:130) E/TiResultSet(32758): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) {code} *Additional details* A DB to get it reproduced can be the one available [here|https://github.com/appcelerator/KitchenSink/blob/master/Resources/etc/testdb.db] (table will be created if not exists).

    Appcelerator JIRA | 4 years ago | Tommy Leung
    java.lang.NullPointerException
  2. 0

    *Problem* Reading a null value from a resultset causes a NullPointer Exception *Test case* {code:javascript} var win = Ti.UI.createWindow(); win.open(); var db = Ti.Database.open('testDB'); db.execute('CREATE TABLE IF NOT EXISTS test(name TEXT, captured INTEGERL);'); db.execute('INSERT INTO test (name, captured) VALUES (?,?)', "111", 222); db.execute('INSERT INTO test (name, captured) VALUES (?,?)', null, null); var results = db.execute('SELECT name, captured FROM test'); while (results.isValidRow()) { var name = results.field(0); var captured = results.fieldByName('captured'); Ti.API.info(name + ' ' + captured); results.next(); } results.close(); db.close(); {code} *Log* {code} E/TiResultSet(32758): (KrollRuntimeThread) [4,1124] Exception getting value for column 7: null E/TiResultSet(32758): java.lang.NullPointerException E/TiResultSet(32758): at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:58) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.getInputStream(TiBlob.java:319) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.guessContentTypeFromStream(TiBlob.java:193) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.loadBitmapInfo(TiBlob.java:209) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.blobFromData(TiBlob.java:182) E/TiResultSet(32758): at org.appcelerator.titanium.TiBlob.blobFromData(TiBlob.java:165) E/TiResultSet(32758): at ti.modules.titanium.database.TiResultSetProxy.internalGetField(TiResultSetProxy.java:113) E/TiResultSet(32758): at ti.modules.titanium.database.TiResultSetProxy.internalGetField(TiResultSetProxy.java:92) E/TiResultSet(32758): at ti.modules.titanium.database.TiResultSetProxy.field(TiResultSetProxy.java:64) E/TiResultSet(32758): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) E/TiResultSet(32758): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:159) E/TiResultSet(32758): at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289) E/TiResultSet(32758): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:185) E/TiResultSet(32758): at android.os.Handler.dispatchMessage(Handler.java:95) E/TiResultSet(32758): at android.os.Looper.loop(Looper.java:130) E/TiResultSet(32758): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) {code} *Additional details* A DB to get it reproduced can be the one available [here|https://github.com/appcelerator/KitchenSink/blob/master/Resources/etc/testdb.db] (table will be created if not exists).

    Appcelerator JIRA | 4 years ago | Tommy Leung
    java.lang.NullPointerException
  3. 0

    SFTP error in OSB

    Oracle Community | 4 years ago | 999730
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Frequent NullPointerException on startup

    GitHub | 3 years ago | JScripter
    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 java.io.ByteArrayInputStream.<init>()
  2. Java RT
    ByteArrayInputStream.<init>
    1. java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:58)
    1 frame
  3. org.appcelerator.titanium
    TiBlob.blobFromData
    1. org.appcelerator.titanium.TiBlob.getInputStream(TiBlob.java:319)
    2. org.appcelerator.titanium.TiBlob.guessContentTypeFromStream(TiBlob.java:193)
    3. org.appcelerator.titanium.TiBlob.loadBitmapInfo(TiBlob.java:209)
    4. org.appcelerator.titanium.TiBlob.blobFromData(TiBlob.java:182)
    5. org.appcelerator.titanium.TiBlob.blobFromData(TiBlob.java:165)
    5 frames
  4. ti.modules.titanium
    TiResultSetProxy.field
    1. ti.modules.titanium.database.TiResultSetProxy.internalGetField(TiResultSetProxy.java:113)
    2. ti.modules.titanium.database.TiResultSetProxy.internalGetField(TiResultSetProxy.java:92)
    3. ti.modules.titanium.database.TiResultSetProxy.field(TiResultSetProxy.java:64)
    3 frames
  5. org.appcelerator.kroll
    V8Runtime.handleMessage
    1. org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
    2. org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:159)
    3. org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289)
    4. org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:185)
    4 frames
  6. Android Platform
    Looper.loop
    1. android.os.Handler.dispatchMessage(Handler.java:95)
    2. android.os.Looper.loop(Looper.java:130)
    2 frames
  7. org.appcelerator.kroll
    KrollRuntime$KrollRuntimeThread.run
    1. org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
    1 frame