0

The jbossews.log segment :

Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "127.xxx.xx3.xx0:27018" , "ok" : 0.0 , "errmsg" : "unauthorized"} at com.mongodb.CommandResult.getException(CommandResult.java:76) at com.mongodb.CommandResult.throwOnError(CommandResult.java:131)

The mongodb.log segment : I think its giving me above exception, because of "command denied: { listDatabases: 1 }" line.

Sun Apr 12 12:30:24.150 [conn1] authenticate db: admin { authenticate: 1, nonce: "#####", user: "admin", key: "*" }
Sun Apr 12 12:31:54.580 [conn3] authenticate db: mydb { authenticate: 1, user: "admin", nonce: "#######", key: "#######" }
Sun Apr 12 12:31:54.582 [conn3] command denied: { listDatabases: 1 }
Sun Apr 12 13:20:14.781 [conn4] authenticate db: admin { authenticate: 1, user: "admin", nonce: "######", key: "#######" }
Sun Apr 12 13:20:15.031 [conn4] command mydb.$cmd command: { $eval: CodeWScope( function (){ return db.getCollectionNames(); }, {}), args: {} } ntoreturn:1 keyUpdates:0 locks(micros) W:223980 reslen:109 224ms
Sun Apr 12 13:20:15.141 [conn5] authenticate db: admin { authenticate: 1, user: "admin", nonce: "######", key: "#######" }

What am I missing ? Any help would be highly appreciated.

  • The user `admin` doing the listDatabases operation in MongoDB doesn't have permission to run the command. Check the permissions of `admin`. – wdberkeley Apr 13 '15 at 15:11
  • The user admin have all the rights , It is the default user of mongoDB carteridge . I think listDatabases operation is executing on the mydb database ,which should get executed on the admin database . I tried running {listDatabases:1} on the mydb databases. Its giving me same error . – Abhishek Nagpure Apr 15 '15 at 16:11

1 Answers1

0

If you used the mongodb cartridge, your username and password should match the one the cartridge install placed in the environment variables. Please use those and see if you get the same error.

Here is an example of authentication code - are you doing something similar to this?

https://github.com/thesteve0/javaparks/blob/master/src/main/java/org/openshift/data/DBConnection.java

TheSteve0
  • 3,530
  • 1
  • 19
  • 25
  • Thanks TheSteve0 for reply, I am using username and password which is in the environment variables. I think its able to authenticate the admin and mydb databases using "admin" password but executing the listDatabases operation/command on mydb database. – Abhishek Nagpure Apr 19 '15 at 10:39