grails 3.1 Exception - org.grails.datastore.mapping.core.ConnectionNotFoundException

时间:2016-04-16 19:00:31

标签: grails grails-3.1

使用grails 3.1version,更频繁地获取此异常,主要是在生产中。

org.grails.datastore.mapping.core.ConnectionNotFoundException: No datastore session found. Call Datastore.connect(..) before calling Datastore.getCurrentSession()
    at grails.mongodb.MongoEntity$Trait$Helper.getDboInternal(MongoEntity.groovy:128) ~[grails-datastore-gorm-mongodb-5.0.1.RELEASE.jar:na]
    at grails.mongodb.MongoEntity$Trait$Helper.getAt(MongoEntity.groovy:118) ~[grails-datastore-gorm-mongodb-5.0.1.RELEASE.jar:na]
    at grails.mongodb.MongoEntity$Trait$Helper.propertyMissing(MongoEntity.groovy:60) ~[grails-datastore-gorm-mongodb-5.0.1.RELEASE.jar:na]
    at my.fanfest.framework.UserController.updatememe(UserController.groovy:1115) ~[classes/:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_95]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_95]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_95]

解决此异常的任何帮助都会对我有所帮助。

1 个答案:

答案 0 :(得分:1)

如果没有任何导致问题的特定代码,很难帮助您。您可以使用此解决方法:

SomeDomain.withNewSession { session -> 
   // your code here 
}