3 Replies Latest reply on Nov 19, 2011 5:35 AM by hantsy bai

    Another org.hibernate.LazyInitializationException I encountered.

    hantsy bai Master

      I use a master/detail view to display data...


      The entity master/detail is one to many(Lazy) relation.


      When I selected an item in the master table, and render the detail table...the org.hibernate.LazyInitializationException was occured.


      I used ViewScoped in the backing bean.


      21:19:41,807 严重    [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-2) Error Rendering View[/crew/crewView.xhtml]: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.telopsys.siorc.model.CrewEnlistment.crewMasterAppraisals, no session or session was closed
           at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:393) [hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
           at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:385) [hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
           at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:125) [hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
           at org.hibernate.collection.internal.PersistentBag.size(PersistentBag.java:243) [hibernate-core-4.0.0.Beta5.jar:4.0.0.Beta5]
           at javax.faces.model.ListDataModel.isRowAvailable(ListDataModel.java:110) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.model.ListDataModel.setRowIndex(ListDataModel.java:185) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.model.ListDataModel.setWrappedData(ListDataModel.java:220) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.model.ListDataModel.<init>(ListDataModel.java:79) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at org.richfaces.component.UISequence.createFacesModel(UISequence.java:92) [richfaces-components-ui-4.1.0.20111101-M4.jar:]
           at org.richfaces.component.UISequence.createExtendedDataModel(UISequence.java:117) [richfaces-components-ui-4.1.0.20111101-M4.jar:]
           at org.richfaces.component.UIDataTableBase.createExtendedDataModel(UIDataTableBase.java:195) [richfaces-components-ui-4.1.0.20111101-M4.jar:]
           at org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:467) [richfaces-components-ui-4.1.0.20111101-M4.jar:]
           at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:278) [richfaces-components-ui-4.1.0.20111101-M4.jar:]
           at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1313) [richfaces-components-ui-4.1.0.20111101-M4.jar:]
           at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UIForm.visitTree(UIForm.java:335) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialRenderPhase(ExtendedPartialViewContextImpl.java:272) [richfaces-core-impl-4.1.0.20111101-M4.jar:]
           at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:194) [richfaces-core-impl-4.1.0.20111101-M4.jar:]
           at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:974) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:369) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS]
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS]
           at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:163) [prettyfaces-jsf2-3.3.0.jar:]
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS]
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS]
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS]
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) [solder-impl-3.1.0.Beta4.jar:]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74) [solder-impl-3.1.0.Beta4.jar:]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.3.0.jar:]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
           at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
           at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
           at java.lang.Thread.run(Thread.java:662) [:1.6.0_29]