Exceptional MongoDB ReplicaSetStatus exceptions using Java driver in Spring

I just deployed the Spring web application on Glassfish. This application contains the Spring bean introduced for the Mongo object, which is pretty simple, it looks something like this:

<bean id="mongo" class="com.mongodb.Mongo"> <constructor-arg value="127.0.0.1" /> <constructor-arg value="27017" /> </bean> 

I run my web application and then use this Mongo object to query db and insert records and something else ... and everything works fine.

But in my server.log file, I get an endless stream of SEVERE error messages. They are NullPointerException and IOException s. They seem to have something to do with ReplicaSetStatus, but I donโ€™t know why it is trying to connect, is it turned on by default?

Does anyone know what causes them? How can I fix the problem or stop everything that causes them?

// EDIT: Exceptions begin immediately after deploying my application. But they do not stop when I turn off my application or even cancel it.

These messages are simply recorded constantly, but from what I see there are only 4 types of errors:

 [#|2011-04-22T17:49:40.818+0900|SEVERE|glassfish3.1|com.mongodb.ReplicaSetStatus|_ThreadID=37;_ThreadName=Thread-1;|can't update node: 27017:27017 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:127) at com.mongodb.DBPort.runCommand(DBPort.java:138) at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149) at com.mongodb..updateAll(ReplicaSetStatus.java:314) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:263) |#] [#|2011-04-22T17:49:40.818+0900|SEVERE|glassfish3.1|com.mongodb.ReplicaSetStatus|_ThreadID=37;_ThreadName=Thread-1;|can't update node: localhost:27017 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:127) at com.mongodb.DBPort.runCommand(DBPort.java:138) at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149) at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314) at com.mongodb.ReplicaSetStatus.ensureMaster(ReplicaSetStatus.java:306) at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:383) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:275) |#] [#|2011-04-22T17:49:41.676+0900|SEVERE|glassfish3.1|com.mongodb.ReplicaSetStatus|_ThreadID=48;_ThreadName=Thread-1;|can't update node: 127.0.0.1:27017 java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect at com.mongodb.DBPort._open(DBPort.java:206) at com.mongodb.DBPort.go(DBPort.java:94) at com.mongodb.DBPort.go(DBPort.java:75) at com.mongodb.DBPort.findOne(DBPort.java:129) at com.mongodb.DBPort.runCommand(DBPort.java:138) at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149) at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314) at com.mongodb.ReplicaSetStatus.ensureMaster(ReplicaSetStatus.java:306) at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:383) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:275) |#] [#|2011-04-22T17:49:41.676+0900|SEVERE|glassfish3.1|com.mongodb.ReplicaSetStatus|_ThreadID=48;_ThreadName=Thread-1;|can't update node: 27017:27017 java.io.IOException: couldn't connect to [/0.0.105.137:27017] bc:java.net.SocketException: Network is unreachable: connect at com.mongodb.DBPort._open(DBPort.java:206) at com.mongodb.DBPort.go(DBPort.java:94) at com.mongodb.DBPort.go(DBPort.java:75) at com.mongodb.DBPort.findOne(DBPort.java:129) at com.mongodb.DBPort.runCommand(DBPort.java:138) at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149) at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314) at com.mongodb.ReplicaSetStatus.ensureMaster(ReplicaSetStatus.java:306) at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:383) at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:275) |#] 
+4
source share
1 answer

Change the definition of Mongo bean in the Spring file as here:

  <constructor-arg value="${db.host}" type="java.lang.String" /> <constructor-arg value="${db.port}" type="int" /> 

If you omit the type attributes, another constructor of the Mongo class is called, where the arguments are instances of type com.mongod.ServerAddress and 27017 are treated as the host name and InetAddress.getAllByName (host) resolves this IP to 0.0.105.137 .

+9
source

All Articles