2 Replies Latest reply on Nov 26, 2007 10:45 AM by sidkennedy

    LazyInitializationException when setting variable

    Roberto Alonso Ramos Zapata Newbie

      I get the following error when trying to set a variable for a taskInstance.

      [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:56)
       at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
       at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:133)
       at org.jbpm.taskmgmt.exe.TaskInstance$$EnhancerByCGLIB$$89d6f052.setVariable(<generated>)
       at org.jbpm.webapp.bean.TaskBean.save(TaskBean.java:179)
       at kernel.bpcs.RequisicionBPCS.guardarTarea(RequisicionBPCS.java:350)
       at kernel.bpcs.RequisicionBPCS.guardar(RequisicionBPCS.java:517)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jbpm.web.AuthenticationFilter.doFilter(AuthenticationFilter.java:56)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jbpm.web.JbpmContextFilter.doFilter(JbpmContextFilter.java:85)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       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:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       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(Unknown Source)
      


      This is the method I'm using to save the task.

      
      public void save(Hashtable taskVariables, String transition)
       {
      
       TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId);
      
       if(taskVariables != null && taskVariables.size() > 0)
       {
       Iterator i = taskVariables.keySet().iterator();
       while(i.hasNext()){
       String key = (String)i.next();
       Object value = taskVariables.get(key);
       taskInstance.setVariable(key, value);
       }
       }
       taskInstance.end(transition);
      
       jbpmContext.save(taskInstance);
      
      
       }
      


      I'm using also the filters that come with the starters-kit.