【发布时间】:2012-11-07 23:36:36
【问题描述】:
在生产服务器的 grails 应用程序中,我遇到了一些问题。 在 securityFilters 我正在注入 springSecurityService 并且在某些时候我会问类似
if(springSecurityService?.currentUser?.client){
...
}
但是系统会抛出错误
Error 500: Internal Server Error
Class
org.hibernate.LazyInitializationException
Message
could not initialize proxy - no Session
Trace
Line | Method
->> 32 | doCall in SecurityFilters$_closure1_closure2_closure4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 82 | doFilterInternal in com.linkedin.grails.profiler.ProfilerFilter
| 190 | invoke . . . . . in org.apache.jk.server.JkCoyoteHandler
| 291 | invoke in org.apache.jk.common.HandlerRequest
| 776 | invoke . . . . . in org.apache.jk.common.ChannelSocket
| 705 | processConnection in ''
| 898 | runIt . . . . . . in org.apache.jk.common.ChannelSocket$SocketConnection
^ 636 | run in java.lang.Thread
第 32 行是我调用上述 if 语句的地方。你知道如何解决这个 LazyInitializationException 吗?我做错了什么?
注意:“client”是该用户所属的域类,但在Person的belongsTo参数中没有提及
谢谢。
【问题讨论】:
标签: grails spring-security lazy-initialization