java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Java Driver with replica sets
    via by Roland Kargl,
  • Error on startup from using Java API
    via by Leif Mortenson,
  • [mongodb-user] Java Driver with replica sets
    via by Roland Kargl,
  • When reloading the same or a new version of an ejb using the mongo driver 2.8.0, NullPointerException occurs continuously in Glassfish logs as the precedent thread was not stopped and tries too use a closed connection. We need to restart Glassfish server each time we want to redeploy our code, which is not possible. This didn't happen with the 2.7.3 version of the driver. [#|2012-06-05T15:18:39.418+0200|WARNING|glassfish3.1.1|com.mongodb.ReplicaSetStatus.wolverine|_ThreadID=24;_ThreadName=Thread-3;|Server seen down: localhost/127.0.0.1:27018 java.lang.NullPointerException at com.mongodb.OutMessage.query(OutMessage.java:38) at com.mongodb.OutMessage.query(OutMessage.java:34) at com.mongodb.DBPort.findOne(DBPort.java:144) at com.mongodb.DBPort.runCommand(DBPort.java:156) at com.mongodb.ReplicaSetStatus$UpdatableNode.update(ReplicaSetStatus.java:507) at com.mongodb.ReplicaSetStatus$Updater.updateAll(ReplicaSetStatus.java:708) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:674) |#] [#|2012-06-05T15:18:39.494+0200|WARNING|glassfish3.1.1|com.mongodb.ReplicaSetStatus.wolverine|_ThreadID=24;_ThreadName=Thread-3;|Server seen down: localhost/127.0.0.1:27017 java.lang.NullPointerException at com.mongodb.OutMessage.query(OutMessage.java:38) at com.mongodb.OutMessage.query(OutMessage.java:34) at com.mongodb.DBPort.findOne(DBPort.java:144) at com.mongodb.DBPort.runCommand(DBPort.java:156) at com.mongodb.ReplicaSetStatus$UpdatableNode.update(ReplicaSetStatus.java:507) at com.mongodb.ReplicaSetStatus$Updater.updateAll(ReplicaSetStatus.java:708) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:674) |#]
    via by Emmanuel VINET,
  • I had redeployed spring web application onto glassfish 3.1, I got endless NullPointerException at at com.mongodb.OutMessage.reset(OutMessage.java:73). (you can also refer this page - http://groups.google.com/group/mongodb-user/browse_thread/thread/a51a1f5f3850ba46/74272391a3ee37ab?hl=en&lnk=gst&q=endless#74272391a3ee37ab ) Here is server log: [#|2011-05-12T01:05:37.251+0900|SEVERE|glassfish3.1|com.mongodb.ReplicaSetS tatus|_ThreadID=27;_ThreadName=Thread-1;|unexpected error getting config from node: localhost:10001 java.lang.NullPointerException at com.mongodb.OutMessage.reset(OutMessage.java:73) at com.mongodb.OutMessage.<init>(OutMessage.java:51) at com.mongodb.OutMessage.query(OutMessage.java:38) at com.mongodb.DBPort.findOne(DBPort.java:142) at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:156) at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:277) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:238) |#] How to reproduce this issue: 1. deploy application to glassfish 2. redeploy same application to glassfish (or, drop the application from the glassfish) 3. you can get that exception endless I inject MongoDB Connecter as spring bean. <bean id="MongoConnector" class="jwdm.core.bean.MongoConnector" p:host="localhost" p:port="10001"> Here is full code of MongoConnector (as Spring bean): public class MongoConnector { private Mongo mongoDB; private String host; private String port; // Return an instance of Mongo public Mongo getMongo() { logger.debug("Retrieving MongoDB"); if (mongoDB == null) { try { List<ServerAddress> addrs = new ArrayList<ServerAddress>(); addrs.add(new ServerAddress(host, Integer.parseInt(port))); mongoDB = new Mongo(addrs); } catch (UnknownHostException e) { logger.error(e.toString()); } catch (MongoException e) { logger.error(e.toString()); } } return mongoDB; } // Retrieve a db public DB getDB(String dbname) { logger.debug("Retrieving db: " + dbname); return getMongo().getDB(dbname); } // Retrieve a collection public DBCollection getCollection(String dbname, String collection) { logger.debug("Retrieving collection: " + collection); return getDB(dbname).getCollection(collection); } ... getter , setter ... } </bean> Before using spring bean style, I was using static factory style without spring. But it produces same exception. Here is static factory style code: public class MongoDBFactory { protected static Logger logger = LoggerFactory.getLogger(MongoDBFactory.class); private static Mongo mongoDB; // Make sure no one can instantiate our factory private MongoDBFactory() { } // Return an instance of Mongo public static Mongo getMongo() { logger.debug("Retrieving MongoDB"); if (mongoDB == null) { try { List<ServerAddress> addrs = new ArrayList<ServerAddress>(); addrs.add(new ServerAddress("localhost", 10001)); //addrs.add(new ServerAddress("leewin12.cafe24.com", 10001)); mongoDB = new Mongo(addrs); } catch (UnknownHostException e) { logger.error(e.toString()); } catch (MongoException e) { logger.error(e.toString()); } } return mongoDB; } // Retrieve a db public static DB getDB(String dbname) { logger.debug("Retrieving db: " + dbname); return getMongo().getDB(dbname); } // Retrieve a collection public static DBCollection getCollection(String dbname, String collection) { logger.debug("Retrieving collection: " + collection); return getDB(dbname).getCollection(collection); } } Thank you for your helps, Greg
    via by Gregory DH Lee,
    • java.lang.NullPointerException at com.mongodb.OutMessage.query(OutMessage.java:79) at com.mongodb.OutMessage.query(OutMessage.java:75) at com.mongodb.DBPort.findOne(DBPort.java:142) at com.mongodb.DBPort.runCommand(DBPort.java:148) at com.mongodb.ConnectionStatus$UpdatableNode.update(ConnectionStatus.java:184) at com.mongodb.ReplicaSetStatus$UpdatableReplicaSetNode.update(ReplicaSetStatus.java:614) at com.mongodb.ReplicaSetStatus$Updater.updateAll(ReplicaSetStatus.java:766) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:736)
    No Bugmate found.