使用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]
解决此异常的任何帮助都会对我有所帮助。
答案 0 :(得分:1)
如果没有任何导致问题的特定代码,很难帮助您。您可以使用此解决方法:
SomeDomain.withNewSession { session ->
// your code here
}