2

我正在使用OpenSessionInViewInterceptor来避免LazyInitializationException。“未能延迟初始化角色集合”即使在使用OSIV模式时也会发生异常

它工作正常,但从某个时候,即使我使用OSIV LazyInitializationException发生。例外情况如下:

SEVERE: Servlet.service() for servlet [appServlet] in context with path [] 
    threw exception [Request processing failed; nested exception is 
    org.apache.tiles.impl.CannotRenderException: ServletException including path 
    '/WEB-INF/views/home/master.jsp'.] with root cause org.hibernate.LazyInitializationException: 
    failed to lazily initialize a collection of role: com..., 
    no session or session was closed 
     at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersisten 
tCollection.java:383) 
     at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(Abs 
tractPersistentCollection.java:375) 
     at 

更奇怪的是,异常日志只存在于日志文件中,导航网站没有问题。

这是怎么发生的?

+0

你在应用程序中执行任何线程吗?你可以在你设置OpenSessionInViewInterceptor的地方显示applicationContext.xml/web.xml的相关部分吗?这也可能有助于查看导致异常的代码区域。 – 2012-04-07 18:03:09

回答

0

在我的情况,这是因为缓存对象。随着缓存对象的分离,LazyInitializationException在访问稍后未被初始化的某些属性时发生。

相关问题