I am trying to connect Grails project with MongoDB, but getting following error
Error creating bean with name 'mongoTransactionManager': Cannot resolve reference to bean 'mongoDatastore' while setting bean property 'datastore'
My DataSource.groovy file-
grails{
mongo{
host ="127.0.0.1"
port ="27017"
username = "blogproject"
password = "mypassword"
databaseName ="blogproject"
}
}
and I have removed following from BuildConfig.groovy
//runtime ":hibernate:3.6.10.12"
//runtime ":database-migration:1.3.8"
//compile ':cache:1.1.1'
and added following in BuildConfig.groovy
compile ":mongodb:3.0.3"
My error stacktrace is as follows-
Error |
2015-08-10 11:17:15,002 [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.CannotGetMongoDbConnectionException: Failed to authenticate to database [blogproject], username = [blogproject], password = [m*********d]
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.CannotGetMongoDbConnectionException: Failed to authenticate to database [blogproject], username = [blogproject], password = [m*********d]
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | 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.CannotGetMongoDbConnectionException: Failed to authenticate to database [blogproject], username = [blogproject], password = [m*********d]
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by CannotGetMongoDbConnectionException: Failed to authenticate to database [blogproject], username = [blogproject], password = [m*********d]
->> 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
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
|Server running. Browse to http://localhost:8090/blogproject
Error |
Forked Grails VM exited with error
I also have added following user in MongoDB for database "blogproject" for authentication
> use blogproject
switched to db blogproject
> show users;
{
"_id" : "blogproject.blogproject",
"user" : "blogproject",
"db" : "blogproject",
"roles" : [
{
"role" : "readWrite",
"db" : "blogproject"
},
{
"role" : "dbAdmin",
"db" : "blogproject"
},
{
"role" : "dbOwner",
"db" : "blogproject"
},
{
"role" : "userAdmin",
"db" : "blogproject"
}
]
}
>
看起来用户名和/或密码错误:
Failed to authenticate to database [blogproject], username = [blogproject], password = [m*********d]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.