【发布时间】:2015-04-04 02:30:19
【问题描述】:
我在 Grails 2.3.7 上创建了一个简单的应用程序来显示我的问题。
我在整个应用程序中只创建了一个控制器和一个服务。这是我的 TestController.groovy:
package testsession
class TestController {
def testingsessionServiceProxy
def index() {
println testingsessionServiceProxy.getSomeVariable()
}
}
我的 TestingsessionService.groovy:
package testsession
import grails.transaction.Transactional
@Transactional
class TestingsessionService {
static scope="session"
static proxy=true
def somevariable=false
def getSomeVariable() {
somevariable
}
}
在运行此应用程序时,我在 TestController.groovy 中为 testingsessionServiceProxy 获得了空值。请参阅下面的跟踪:
....Error
|
2015-04-02 18:09:28,122 [http-bio-8080-exec-7] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /TestSession/test/index
Cannot invoke method getSomeVariable() on null object. Stacktrace follows:
Message: Cannot invoke method getSomeVariable() on null object
Line | Method
->> 6 | index in testsession.TestController
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 200 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
【问题讨论】:
标签: grails