java.lang.NullPointerException

Google Groups | Yuri Gurevich | 2 years ago
  1. 0

    exception while running MongoDB client

    Google Groups | 2 years ago | Yuri Gurevich
    java.lang.NullPointerException
  2. 0

    I use the following update: collection.update(q, new BasicDBObject("$pull", new BasicDBObject("x",null)) //where q is some object which queries the correct doc in the collection and "x" corresponds to an array and I receive the following error: 2012.01.05 10:34:36 root - Error: java.lang.NullPointerException: can't save a null object java.lang.NullPointerException: can't save a null object at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:95) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:86) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:142) at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:345) at com.mongodb.DBCollection.update(DBCollection.java:165) at com.mongodb.DBCollection.update(DBCollection.java:197) at com.mongodb.DBCollection.update(DBCollection.java:209) The null is created in the first place as a result of using the $unset: collection.update(q, new BasicDBObject("$unset", new BasicDBObject("x"+".$",1))) //where q is some object which queries the correct doc in the collection and "x" corresponds to an array I cannot use the $pull in replacement of $unset because i would require exact matching, which doesn't seem possible as documented: "Because of this feature, to use the embedded doc as a match criteria, you cannot do exact matches on array elements." I had assumed that using the null pointer reference was ok based on the post by Andrew Wharton specified in: http://www.mongodb.org/display/DOCS/Java+Types Is this the correct way to be doing this? The only other way to accomplish this would be to query the entire array, modify it, then insert it back; but I would rather not do this as this could lead to a race condition.

    JIRA | 5 years ago | Josh Rogers
    java.lang.NullPointerException: can't save a null object
  3. 0

    After running for some days without problems I just get NullPointerExceptions for every operation. I restarted my application (not the server) and the mongo-driver worked again. The first error: java.lang.NullPointerException: null at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:274) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:205) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:284) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DB.command(DB.java:152) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DB.command(DB.java:141) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DB.getLastError(DB.java:302) ~[mongo-java-driver-2.3.jar:na] and afterwards for example: Caused by: java.lang.NullPointerException: null at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:274) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:205) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:284) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DB.command(DB.java:152) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBCollection.getCount(DBCollection.java:642) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBCollection.getCount(DBCollection.java:616) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBCursor.count(DBCursor.java:555) ~[mongo-java-driver-2.3.jar:na] java.lang.NullPointerException: null at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:274) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:151) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:141) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:317) ~[mongo-java-driver-2.3.jar:na] at com.mongodb.DBCollection.update(DBCollection.java:112) ~[mongo-java-driver-2.3.jar:na]

    JIRA | 6 years ago | Daniel Peters
    java.lang.NullPointerException: null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I use the following update: collection.update(q, new BasicDBObject("$pull", new BasicDBObject("x",null)) //where q is some object which queries the correct doc in the collection and "x" corresponds to an array and I receive the following error: 2012.01.05 10:34:36 root - Error: java.lang.NullPointerException: can't save a null object java.lang.NullPointerException: can't save a null object at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:95) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:86) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:142) at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:345) at com.mongodb.DBCollection.update(DBCollection.java:165) at com.mongodb.DBCollection.update(DBCollection.java:197) at com.mongodb.DBCollection.update(DBCollection.java:209) The null is created in the first place as a result of using the $unset: collection.update(q, new BasicDBObject("$unset", new BasicDBObject("x"+".$",1))) //where q is some object which queries the correct doc in the collection and "x" corresponds to an array I cannot use the $pull in replacement of $unset because i would require exact matching, which doesn't seem possible as documented: "Because of this feature, to use the embedded doc as a match criteria, you cannot do exact matches on array elements." I had assumed that using the null pointer reference was ok based on the post by Andrew Wharton specified in: http://www.mongodb.org/display/DOCS/Java+Types Is this the correct way to be doing this? The only other way to accomplish this would be to query the entire array, modify it, then insert it back; but I would rather not do this as this could lead to a race condition.

    JIRA | 5 years ago | Josh Rogers
    java.lang.NullPointerException: can't save a null object
  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 com.mongodb.DBTCPConnector.say()
    2. MongoDB Java Driver
      DBCollection.update
      1. com.mongodb.DBTCPConnector.say(DBTCPConnector.java:154)
      2. com.mongodb.DBTCPConnector.say(DBTCPConnector.java:138)
      3. com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:348)
      4. com.mongodb.DBCollection.update(DBCollection.java:165)
      4 frames
    3. mongoDB
      MongoDbClient.inviteFriend
      1. mongoDB.MongoDbClient.inviteFriend(Unknown Source)
      1 frame
    4. edu.usc.bg
      ClientThread.run
      1. edu.usc.bg.base.DBWrapper.inviteFriend(DBWrapper.java:158)
      2. edu.usc.bg.workloads.CoreWorkload.doActioninviteFriend(CoreWorkload.java:2423)
      3. edu.usc.bg.workloads.CoreWorkload.doTransaction(CoreWorkload.java:1073)
      4. edu.usc.bg.base.ClientThread.run(ClientThread.java:201)
      4 frames