0

I recently created an mongolab account on a sandbox platform (so no admin priviledges). I have a simple testcase application to integrate Hibernate OGM + JPA 2.1 with my mongo database. When i try to run my application i get the following error(singnificant part):

Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "ds062797.mongolab.com:62797" , "ok" : 0.0 , "errmsg" : "not authorized on admin to execute command { listDatabases: 1 }" , "code" : 13}
at com.mongodb.CommandResult.getException(CommandResult.java:76)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:131)
at com.mongodb.Mongo.getDatabaseNames(Mongo.java:397)
at org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider.extractDatabase(MongoDBDatastoreProvider.java:152)
... 34 more

I've done some digging in Hibernate ORM's documentation here and the following lines caught my eye:

The user defined with USERNAME must have the privileges for the creation of a new database. The database will have the name defined with DATABASE. Accepts "true" or "false".

Is there any way I can override this in Hibernate OGM? Or maybe someone used another provider that doesn't have this limitation? (tried to setup eclipselink with no luck)

P.S.: I am aware that i can connect to mongolab with the MongoDB java driver creating a MongoClient, been there done that. I want to stick to an JPA setup.

Community
  • 1
  • 1
  • Have you tried DataNucleus JPA with mongodb? No idea on whether that "restriction" applies cos can't say I understand what it says – Neil Stockton Mar 01 '15 at 13:41

1 Answers1

1

Seems you are running into OGM-733 which has been fixed just recently. It should work with Hibernate OGM 4.1.2.Final.

Gunnar
  • 18,095
  • 1
  • 53
  • 73
  • Thanks for the tip @Gunnar. I've managed last night to setup the eclipselink provider with mongo, works like a charm. If someone else strugles to make a clean setup i'll put the test project on github, maybe with both setups (eclipselink and hibernate ogm). You gave a fair answer and you have my vote. – Alex Dutescu Mar 02 '15 at 17:28