一样的nutz框架集成mongodb的程序,在别人电脑上eclipse上运行能正常插入数据,而放到我的电脑上,就报这个错误。如果mongdb在启动时auth不是true的话,是可以正常插入的,这是为什么呢。
运行错误:
2016-12-2 16:35:25 com.mongodb.diagnostics.logging.JULLogger log
信息: No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=MULTIPLE, all=[ServerDescription{address=10.144.100.215:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
2016-12-2 16:35:25 com.mongodb.diagnostics.logging.JULLogger log
信息: Exception in monitor thread while connecting to server 10.144.100.215:27017
com.mongodb.MongoSecurityException: Exception authenticating
at com.mongodb.connection.NativeAuthenticator.authenticate(NativeAuthenticator.java:48)
at com.mongodb.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:99)
at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:44)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.mongodb.MongoCommandException: Command failed with error 18: 'auth failed' on server 10.144.100.215:27017. The full response is { "ok" : 0.0, "errmsg" : "auth failed", "code" : 18 }
at com.mongodb.connection.CommandHelper.createCommandFailureException(CommandHelper.java:170)
at com.mongodb.connection.CommandHelper.receiveCommandResult(CommandHelper.java:123)
at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
at com.mongodb.connection.NativeAuthenticator.authenticate(NativeAuthenticator.java:46)
... 5 more
db.js配置如下:
zMongo : {
args : [ "perfdba1","hope123","10.144.100.101",27017,"nwimscmdb" ], // 或者不写参数,默认就是127.0.0.1和27017
//args : ["10.144.100.215", 27017],
factory : "org.nutz.mongo.ZMongo#me"
},
zMoDB : {
args : [ "nwimscmdb" ], // 数据库名称
factory : "$zMongo#db"
},
zMoCo : {
args : [ "tomcat" ],
factory : "$zMoDB#c"
}