2 Replies Latest reply on Aug 7, 2008 3:58 AM by fero kocun

    Lazy Initaslization Error

    Saurabh Khattar Newbie

      I have made a small BPM web application. In one of the methods in servlet I am getting the instances for a particular user:

      private void getProcessDetails(HttpServletRequest request, HttpServletResponse response) {
      
       HttpSession session = request.getSession();
      
       List jbpmTaskInstances = new ArrayList();
      
       JbpmConfiguration jbpmConfiguration = JbpmEncompassConfiguration.instance().getJbpmConfiguration();
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
      
      
       Session jbpmContextSession = jbpmContext.getSession();
      
      
       String actorPmId = new String("PM");
       String actorCordId = new String("Coordinator");
      
       List actorsList = new ArrayList();
       actorsList.add(actorPmId);
       List pooledPmTaskInstances = jbpmContext.getTaskMgmtSession().findTaskInstances(actorsList);
       List jbpmPmTaskInstanceList = jbpmContextSession.createQuery("from org.jbpm.taskmgmt.exe.TaskInstance ti where ti.start is null and ti.end is null and actorId = '"+actorPmId+"'").list();
       //add pooledTaskInstances to taskList
       jbpmPmTaskInstanceList.addAll(pooledPmTaskInstances);
       jbpmTaskInstances.addAll(jbpmPmTaskInstanceList);
      
       actorsList = new ArrayList();
       actorsList.add(actorCordId);
       List pooledCordTaskInstances = jbpmContext.getTaskMgmtSession().findTaskInstances(actorsList);
       List jbpmCordTaskInstanceList = jbpmContextSession.createQuery("from org.jbpm.taskmgmt.exe.TaskInstance ti where ti.start is null and ti.end is null and actorId = '"+actorCordId+"'").list();
       //add pooledTaskInstances to taskList
       jbpmCordTaskInstanceList.addAll(pooledCordTaskInstances);
       jbpmTaskInstances.addAll(jbpmCordTaskInstanceList);
      
       Iterator iAll = jbpmTaskInstances.iterator();
       Iterator iPm = jbpmPmTaskInstanceList.iterator();
       Iterator iCord = jbpmCordTaskInstanceList.iterator();
      
       List jbpmProcessInstances = new ArrayList();
      
       while(iAll.hasNext()){
       TaskInstance ti = (TaskInstance) iAll.next();
       ProcessInstance processInstance = ti.getProcessInstance();
       jbpmProcessInstances.add(processInstance);
       }
      
      
      
       session.setAttribute("pmTaskList", jbpmPmTaskInstanceList);
       session.setAttribute("cordTaskList", jbpmCordTaskInstanceList);
       session.setAttribute("allTaskList", jbpmProcessInstances);
      
      
      
       //jbpmContextSession.close();
       jbpmContext.close();
      
       }
      
      



      I set arraylist of process instances in the session. But when I try to access process instances in jsp it gives the following error:


      
      10:13:39,214 ERROR [LazyInitializationException] could not initialize proxy - the owning Session was closed
      org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
       at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:60)
       at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
       at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)
       at org.jbpm.graph.exe.ProcessInstance$$EnhancerByCGLIB$$614637f6.getContextInstance(<generated>)
       at org.apache.jsp.jsp.index_jsp._jspService(index_jsp.java:121)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)


      Please some one help me....