Just want to check here, did any body come across this issue
Caused by: com.mongodb.MongoException: not authorized for insert on myworld.Users
at com.mongodb.CommandResult.getException(CommandResult.java:100) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.CommandResult.throwOnError(CommandResult.java:134) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:142) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:183) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:155) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:270) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:226) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBCollection.insert(DBCollection.java:75) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBCollection.insert(DBCollection.java:59) [mongo-java-driver-2.10.1.jar:]
at com.mongodb.DBCollection.insert(DBCollection.java:104) [mongo-java-driver-2.10.1.jar:]
at com.sandeep.myworld.dao.base.MongoAdapter.insertUser(MongoAdapter.java:46) [classes:]
at com.sandeep.myworld.dao.impl.UserServiceDaoImpl.importUser(UserServiceDaoImpl.java:19) [classes:]
at com.sandeep.myworld.services.impl.UserService.importUser(UserService.java:29) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79]
at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)
at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:181)
... 31 more
I am trying to connect the mongo DB from Openshift. It seems the connection object is returned, collection object also returned, but when in executed the line table.insert, method as below, the exception came
DB db = getDBConnection(this.dbname);
DBCollection table = db.getCollection(this.dbcollcetion.name());
BasicDBObject document = new BasicDBObject();
Field [] attributes = object.getClass().getDeclaredFields();
try {
for(Field field: attributes) {
field.setAccessible(true);
document.put(field.getName(), field.get(object));
}
} catch (IllegalArgumentException e) {
System.out.println("Exception in setting fields to mongo basicobject");
e.printStackTrace();
} catch (IllegalAccessException e) {
System.out.println("Exception in setting fields to mongo basicobject");
e.printStackTrace();
}
WriteResult write = table.insert(document);
return result;
Any help much appreciated, is there anything to do with the access in mongo db, I have checked the system.users collcetion, I can see the admin user there with readonly as false.
have a great day
Check if the db name used in this line
is the name of your application created in openshift.
Looks like OpenShift precreates a DB with that name in MongoDB and you are authorized to use it. But you are not authorized to create and use a new one.
You can install rockmongo in openshift and see the already existing DBs.