So. I tried something else today. This is about as simple as I can get the
app. It runs fine without the --auth flag for mongod, but with the --auth it
fails.
I am at a complete loss as to why. Here is my situation:
I have a local copy of MongoDb 2.6 installed on my machine. I added two
users, as you can see by the mongo shell output:
switched to db admin
show users
{
"_id" : "admin.admin",
"user" : "admin",
"db" : "admin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
{
"_id" : "admin.persondb",
"user" : "persondb",
"db" : "admin",
"roles" : [
{
"role" : "dbOwner",
"db" : "person"
},
{
"role" : "readWrite",
"db" : "person"
}
]
}
use person
switched to db person
show users
{
"_id" : "person.persondb",
"user" : "persondb",
"db" : "person",
"roles" : [
{
"role" : "dbOwner",
"db" : "person"
},
{
"role" : "readWrite",
"db" : "person"
}
]
}
And this is the entirety of my DataSource.groovy:
// environment specific settings
environments {
development {
grails {
mongo {
host = 'localhost'
port = 27017
databaseName = "person"
username: "persondb"
password: "persondb"
}
}
}
}
I created a simple domain class:
package com.bnsf
import org.bson.types.ObjectId
class Person {
ObjectId id
String firstName
String lastName
static mapping = {
lastName index:true
sort lastName:"asc"
}
static constraints = {
}
}
And generated a controller for the class, since it looks like the
scaffolding doesn't work with mongo. No problem..
BuildConfig.groovy plugins dependencies:
plugins {
build ":tomcat:7.0.52.1"
compile ":scaffolding:2.0.2"
compile ":mongodb:3.0.0"
compile ":twitter-bootstrap:3.1.1"
compile ":jquery-ui:1.10.3"
compile ":codenarc:0.19"
test ":code-coverage:1.2.7"
// plugins needed at runtime but not for compilation
runtime ":jquery:1.11.0.2"
runtime ":resources:1.2.1"
}
That's it.
When I run run-app I get the following error:
|Running Grails application
Error |
2014-04-28 12:53:36,462 [localhost-startStop-1] ERROR
context.GrailsContextLoader - Error initializing the application: Error
creating bean with name 'mongoTransactionManager': Cannot resolve reference
to bean 'mongoDatastore' while setting bean property 'datastore'; nested
exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mongoDatastore': FactoryBean threw exception on
object creation; nested exception is
org.springframework.data.mongodb.UncategorizedMongoDbException: {
"serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized
on person to execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}; nested exception is com.mongodb.CommandFailureException: {
"serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized
on person to execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}
Message: Error creating bean with name 'mongoTransactionManager': Cannot
resolve reference to bean 'mongoDatastore' while setting bean property
'datastore'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'mongoDatastore': FactoryBean threw exception on object creation;
nested exception is
org.springframework.data.mongodb.UncategorizedMongoDbException: {
"serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized
on person to execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}; nested exception is com.mongodb.CommandFailureException: {
"serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized
on person to execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}
Line | Method
->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name
'mongoDatastore': FactoryBean threw exception on object creation; nested
exception is org.springframework.data.mongodb.UncategorizedMongoDbException:
{ "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized
on person to execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}; nested exception is com.mongodb.CommandFailureException: {
"serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized
on person to execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}
->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
Caused by UncategorizedMongoDbException: { "serverUsed" : "localhost:27017"
, "ok" : 0.0 , "errmsg" : "not authorized on person to execute command {
createIndexes: \"person\", indexes: [ { name: \"lastName_1\", ns:
\"person.person\", key: { lastName: 1 } } ] }" , "code" : 13}; nested
exception is com.mongodb.CommandFailureException: { "serverUsed" :
"localhost:27017" , "ok" : 0.0 , "errmsg" : "not authorized on person to
execute command { createIndexes: \"person\", indexes: [ { name:
\"lastName_1\", ns: \"person.person\", key: { lastName: 1 } } ] }" , "code"
: 13}
->> 285 | initializeIndices in
org.grails.datastore.mapping.mongo.MongoDatastore
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 276 | createMongoTemplate in ''
| 221 | afterPropertiesSet in ''
| 54 | getObject in
org.grails.datastore.gorm.mongo.bean.factory.MongoDatastoreFactoryBean
| 262 | run . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
Caused by CommandFailureException: { "serverUsed" : "localhost:27017" , "ok"
: 0.0 , "errmsg" : "not authorized on person to execute command {
createIndexes: \"person\", indexes: [ { name: \"lastName_1\", ns:
\"person.person\", key: { lastName: 1 } } ] }" , "code" : 13}
->> 76 | getException in com.mongodb.CommandResult
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 131 | throwOnError in ''
| 347 | createIndex in com.mongodb.DBCollectionImpl
| 564 | createIndex in com.mongodb.DBCollection
| 663 | ensureIndex in ''
| 603 | ensureIndex in ''
| 341 | doInDB . in org.grails.datastore.mapping.mongo.MongoDatastore$6
| 285 | initializeIndices in
org.grails.datastore.mapping.mongo.MongoDatastore
| 276 | createMongoTemplate in ''
| 221 | afterPropertiesSet in ''
| 54 | getObject in
org.grails.datastore.gorm.mongo.bean.factory.MongoDatastoreFactoryBean
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . in java.lang.Thread
Error |
Forked Grails VM exited with error
--
View this message in context: http://grails.1312388.n4.nabble.com/ANN-GORM-for-MongoDB-3-0-tp4656307p4656407.html
Sent from the Grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email