`
yuanke
  • 浏览: 73388 次
  • 性别: Icon_minigender_2
  • 来自: 临沂
社区版块
存档分类
最新评论

延迟加载 出问题了,有那位见过这个异常?

    博客分类:
  • J2EE
阅读更多
我把 lazy 设 为 false 不行,

  在web.xml中加入
<filter>
        <filter-name>hibernateFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate.support.OpenSessionInViewFilter</filter-class>
    </filter>
   <filter-mapping>
        <filter-name>hibernateFilter</filter-name>
        <url-pattern>*.html</url-pattern>
    </filter-mapping> 
查了半天,还是不嫩解决,真郁闷啊

[demo] DEBUG [http-8083-3] BaseAction.getLookupMapName(226) | BaseAction: getLookupMapName( keyName = searchUserSysmodule )
[demo] DEBUG [http-8083-3] BaseAction.getLookupMapName(238) | BaseAction: keyName not found in resource bundle with locale zh_CN
[demo] DEBUG [http-8083-3] BaseAction.getLookupMapName(249) | keyName 'searchUserSysmodule' not found in resource bundle with locale zh_CN
[demo] DEBUG [http-8083-3] SysmoduleAction.searchUserSysmodule(280) | Entering 'searchUserPleat' method
[demo] DEBUG [http-8083-1] UserMessageAction.search(24) | Entering 'UserMessageAction' method
Hibernate: select sysuser0_.id as id0_, sysuser0_.name as name0_, sysuser0_.password as password0_, sysuser0_.truename as truename0_, sysuser0_.type as type0_, sysuser0_.status as status0_, sysuser0_.department as department0_, sysuser0_.revisable as revisable0_ from sysuser sysuser0_ where sysuser0_.id=?
Hibernate: select plate0_.id as id, plate0_.parentid as parentid, plate0_.name as name, plate0_.status as status, plate0_.serialnumber as serialnu5_, plate0_.level as level, plate0_.content as content, plate0_.target as target, plate0_.url as url, plate0_.ifinter as ifinter, plate0_.filename as filename, plate0_.mansort as mansort, plate0_.havefile as havefile, plate0_.revisable as revisable, plate0_.showtype as showtype, plate0_.ifindex as ifindex from plate plate0_ where (parentid=? )And(status=? ) order by  plate0_.serialnumber desc
[demo] ERROR [http-8083-1] PersistentCollection.initialize(198) | Failed to lazily initialize a collection
net.sf.hibernate.HibernateException: collection was evicted
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3293)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
at net.sf.hibernate.collection.PersistentCollection.write(PersistentCollection.java:84)
at net.sf.hibernate.collection.Bag.retainAll(Bag.java:340)
at cn.com.xunuo.webapp.action.UserMessageAction.search(UserMessageAction.java:41)
at cn.com.xunuo.webapp.action.UserMessageAction.unspecified(UserMessageAction.java:65)
at cn.com.xunuo.webapp.action.BaseAction.execute(BaseAction.java:129)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.com.xunuo.webapp.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:113)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
[demo] ERROR [http-8083-1] ActionExceptionHandler.logException(75) | net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
at net.sf.hibernate.collection.PersistentCollection.write(PersistentCollection.java:84)
at net.sf.hibernate.collection.Bag.retainAll(Bag.java:340)
at cn.com.xunuo.webapp.action.UserMessageAction.search(UserMessageAction.java:41)
at cn.com.xunuo.webapp.action.UserMessageAction.unspecified(UserMessageAction.java:65)
at cn.com.xunuo.webapp.action.BaseAction.execute(BaseAction.java:129)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.com.xunuo.webapp.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:113)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: net.sf.hibernate.HibernateException: collection was evicted
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3293)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
... 37 more

[demo] ERROR [http-8083-1] ActionExceptionHandler.logException(75) | net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
at net.sf.hibernate.collection.PersistentCollection.write(PersistentCollection.java:84)
at net.sf.hibernate.collection.Bag.retainAll(Bag.java:340)
at cn.com.xunuo.webapp.action.UserMessageAction.search(UserMessageAction.java:41)
at cn.com.xunuo.webapp.action.UserMessageAction.unspecified(UserMessageAction.java:65)
at cn.com.xunuo.webapp.action.BaseAction.execute(BaseAction.java:129)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.com.xunuo.webapp.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:113)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: net.sf.hibernate.HibernateException: collection was evicted
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3293)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
... 37 more

分享到:
评论

相关推荐

    mybatis延迟加载样例

    当我们在查询一个实体对象时,如果它与另一个或多个实体有关联,但这些关联对象并未在当前查询中被明确要求,那么MyBatis会等到我们首次访问这些关联对象时才执行对应的SQL查询,这就是延迟加载的核心思想。...

    jquery图片延迟加载

    为了解决这个问题,开发人员引入了“图片延迟加载”技术,jQuery作为一款广泛使用的JavaScript库,提供了实现这一功能的强大工具。本文将深入探讨jQuery图片延迟加载的概念、优势以及实现方法。 **一、什么是图片...

    Flex 延迟加载 问题说明 处理 实现

    延迟加载是一种资源管理策略,它的核心思想是在用户实际需要某个资源的时候才去加载这个资源,而不是一开始就加载所有资源。这种方式可以显著减少初始加载时间,提高用户体验。 ##### 3.2 优势 1. **减少初始加载...

    图片延迟加载的jq

    这样可以避免一次性加载所有图片导致的页面加载时间过长的问题,尤其是对于含有大量图片的页面,效果尤为显著。 **二、使用步骤** 1. **引入依赖**:首先,在HTML文件中引入jQuery库和jQuery.lazyload插件。例如: ...

    延迟加载 html优化

    延迟加载则避免了这个问题,它将非首屏内容的加载推迟到用户滚动到相应位置时才进行。这样,用户在页面顶部就能看到完整的内容,无需等待整个页面完全加载完毕。 在HTML优化中,我们可以利用JavaScript库来实现延迟...

    Mybatis延迟加载和缓存

    为了解决这个问题,Mybatis 提供了延迟加载功能,使得关联对象在调用相关方法时才加载,提高程序性能。 实现延迟加载,首先需要在映射文件中开启该功能,并正确配置关联关系。例如: ```xml ``` 这里 `orders...

    hibernate延迟加载解决

    尽管延迟加载有诸多优点,但也会带来一些问题,比如“懒加载异常”(LazyInitializationException)。当会话关闭后,尝试访问懒加载的关联对象时,会出现此异常,因为此时已经没有有效的Session来执行数据库查询。 ...

    jquery 图片延迟加载

    为了解决这个问题,"图片延迟加载"(Lazy Load)技术应运而生。jQuery作为广泛使用的JavaScript库,提供了实现图片延迟加载的便利方法。 ### 一、什么是图片延迟加载? 图片延迟加载,也称为懒加载,是一种优化...

    原生js延迟加载

    在这个延迟加载的场景中,面向对象编程可能涉及以下关键概念: 1. **构造函数**:用于初始化新创建的对象。在延迟加载的例子中,我们可以定义一个构造函数,比如`LazyLoader`,它接收图片数组或其他需要延迟加载的...

    延迟加载库 DelayLoadHook.zip

    4. **异常处理**:在某些情况下,如果DLL加载失败,系统会抛出一个异常。为了处理这种情况,需要在代码中加入适当的异常处理机制。 总的来说,延迟加载库是一种实用的技术,可以在保持程序性能的同时减少资源消耗。...

    js设置延迟加载

    这段代码定义了一个`sleep`函数,它通过循环等待直到达到指定的延迟时间。需要注意的是,由于JavaScript是单线程执行的,因此这种方法会阻塞其他任务的执行,可能会导致页面失去响应。 #### 性能考虑与最佳实践 ...

    hibernate 延迟加载深入剖析

    在这个映射文件中,`lazy="true"`表明了`addresses`集合属性将采用延迟加载的方式。这意味着当`Person`对象被加载时,并不会立即加载`addresses`集合中的所有`Address`对象。 **延迟加载触发时机** 延迟加载会在...

    HTML延迟加载图片 html图片延迟加载技术大全.zip

    2. **jQuery LazyLoad插件**:这是一个流行的jQuery插件,它提供了简单易用的接口来实现图片的懒加载。通过`$(window).lazyload()`方法,配合适当的配置选项,可以轻松实现图片延迟加载。 3. **Intersection ...

    Hibernate延迟加载以及利用Spring

    1. **修改Fetch策略**:将Fetch策略设置为`fetch="join"`,即在查询主对象的同时通过JOIN查询的方式加载关联对象,这样就不会抛出延迟加载异常。 2. **禁用延迟加载**:将`lazy="false"`,这样就会在查询主对象时...

    ssh_inte2模板常用方法&延迟加载问题

    此时,如果存在延迟加载的对象,其加载动作还没来得及执行,Session就已经被销毁,那么在后续尝试访问这些延迟加载属性时,就会抛出异常,提示对象已经被托管给事务,无法再执行数据库操作。 为了解决这个问题,...

    html延迟加载JS和CSS

    在这个例子中,`non-critical.css`只会在视口宽度至少为768px时加载,这有助于减少首次加载时不必要的网络请求。 在给定的文件`lazyLoadJC.js`中,可能实现了一个JavaScript库,用于延迟加载JS和CSS资源。这个库...

    网页图片延迟加载插件

    网页图片延迟加载,也称为懒加载(Lazy Loading),是一种优化网页性能的技术,它允许网页在初始加载时只加载可见区域的图片,而将其他非可视区域的图片推迟到用户滚动到相应位置时再加载。这种技术可以显著减少网页...

    ListView 延迟加载图片 改进

    标题“ListView延迟加载图片改进”正是针对这个问题,通过延迟加载技术来提升用户体验。 延迟加载(Lazy Loading)是一种策略,它不一次性加载所有图片,而是当用户滚动到某一个列表项时,才加载对应的图片。这种...

    jquery延迟加载图片

    **jQuery延迟加载图片技术详解** 在网页设计中,图片往往是页面加载速度的瓶颈。为了提高网页的加载效率和用户体验,开发者通常会采用延迟加载(Lazy Loading)技术,尤其是在图片众多的场景下。jQuery库提供了简单...

    网页图片延迟加载案例.rar

    这是一款有关网页图片延迟加载的小案例,主要包括了图片随滚动条延迟加载、整个页面loading延迟加载、图片延迟加载、iframe打开页面延迟加载的技术。通过延迟加载技术可以提升网站的性能,有需要的朋友可以下载看看...

Global site tag (gtag.js) - Google Analytics