I am trying to use hibernate-ogm for accessing my mongodb.
But i always get an exception that the user cannot authenticate:
Caused by: org.hibernate.HibernateException: OGM001213: MongoDB authentication failed with username [x]
I have looked at the source code and found the following code: if ( config.getUsername() != null ) { DB admin = this.mongo.getDB( "admin" ); boolean auth = admin.authenticate( config.getUsername(), config.getPassword().toCharArray() ); if ( !auth ) { throw log.authenticationFailed( config.getUsername() ); }
}
Why does mongodb connects against the "admin" database??
When i change this line to use the specified database (config.getDatabaseName()) it works fine.
|