存储在HTTP会话中的对象的LazyInitializationException

时间:2014-11-03 17:25:27

标签: spring hibernate grails spring-security

我在Grails项目中有一个场景,我将域对象存储在HTTP会话中。这可能不是一个很好的做法,但我现在无法改变它。

我遇到的问题是,如果我遇到未处理的异常,然后尝试注销(身份验证使用Spring Security),我将无法注销并将获得另一个LazyInitialization异常(甚至不会在同一个集合中前。)

我不明白的是Spring Security正在尝试使用HTTP会话中的这些分离的域对象。

如果我查看Grails文档,可以找到有关如何将内容重新附加到Hibernate会话的示例:http://grails.org/doc/latest/ref/Domain%20Classes/attach.html。但在这种情况下,我甚至不想重新附加这些对象。我已经完成了他们。看起来Spring安全性正在寻找HTTP会话并试图对这些对象做些什么,但我不确定是什么,或者如何修复它。

完整堆栈跟踪:

    Line | Method
->> 1418 | writeOrdinaryObject in java.io.ObjectOutputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1177 | writeObject0        in     ''
|   1547 | defaultWriteFields  in     ''
|   1508 | writeSerialData     in     ''
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|   1547 | defaultWriteFields  in     ''
|   1508 | writeSerialData     in     ''
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|    347 | writeObject . . . . in     ''
|   1128 | writeObject         in java.util.HashMap
|    988 | invokeWriteObject . in java.io.ObjectStreamClass
|   1495 | writeSerialData     in java.io.ObjectOutputStream
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|   1547 | defaultWriteFields  in     ''
|   1508 | writeSerialData     in     ''
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|   1547 | defaultWriteFields  in     ''
|   1508 | writeSerialData     in     ''
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|   1547 | defaultWriteFields  in     ''
|   1508 | writeSerialData     in     ''
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|    347 | writeObject . . . . in     ''
|   1129 | writeObject         in java.util.HashMap
|    988 | invokeWriteObject . in java.io.ObjectStreamClass
|   1495 | writeSerialData     in java.io.ObjectOutputStream
|   1431 | writeOrdinaryObject in     ''
|   1177 | writeObject0        in     ''
|    347 | writeObject . . . . in     ''
|     74 | doFilter            in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
|   1145 | runWorker . . . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run                 in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . in java.lang.Thread

0 个答案:

没有答案