2 Replies Latest reply on Mar 20, 2007 7:12 AM by Peter Brewer

    jBPM and LIE

    Peter Brewer Novice

      I'm new to using jBPM and am trying to query the jBPM database objects.

      I run a query that returns summary data containing the process and the number of tasks for the process. The summary data is displayed, however, the user then trys to click a process to display a list of tasks for that process, but receives a LazyInitializationException instead.

      How can I make the jBPM Session behave in similar manner to the seam managed PC? Is there anyway to make jBPM use seams entity manager instead?

      Any ideas on how to solve this problem would be greatly appreciated.

      Cheers, Pete.

      Named query called jbpm.getProcesses

      SELECT
       count(t.processDefinition.id), t.processDefinition.id
      FROM
       org.jbpm.taskmgmt.exe.PooledActor pooledActor
      JOIN
       pooledActor.taskInstances ti
      JOIN
       ti.task t
      WHERE
       pooledActor.actorId in ( :actorIds )
      AND
       ti.actorId is null
      AND
       ti.isSuspended != true
      AND
       ti.isOpen = true
      GROUP BY
       t.processDefinition.id
      


      Code that is used in a summary process list:
       public List<ProcessResult> getProcessSummary(List<String> pooledActorIds) {
       org.hibernate.Query taskQuery = jbpmContext.getSession().getNamedQuery("jbpm.getProcesses") ;
       taskQuery.setParameterList("actorIds", pooledActorIds) ;
       List<ProcessResult> results = new ArrayList<ProcessResult>() ;
       List<Object[]> queryResults = taskQuery.list() ;
       for (Object[] result : queryResults) {
       ProcessDefinition process = (ProcessDefinition) jbpmContext.getSession().load(ProcessDefinition.class, (Serializable)result[1]) ;
       results.add(new ProcessResult((Long)result[0], process)) ;
       }
       return results ;
      


      Code that causes a LIE
       public Collection<Task> getTasksFromProcess(ProcessResult process) {
       if (process != null) {
       // next line causes LIE
       Map<String, Task> tasks = (Map<String, Task>) process.getProcess().getTaskMgmtDefinition().getTasks() ;
       return tasks.values() ;
       } else {
       return null;
       }
       }
      
      


      The LIE in the log
      org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.jbpm.graph.def.ProcessDefinition.definitions, no session or session was closed
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
       at org.hibernate.collection.AbstractPersistentCollection.readElementByIndex(AbstractPersistentCollection.java:151)
       at org.hibernate.collection.PersistentMap.get(PersistentMap.java:146)
       at org.jbpm.graph.def.ProcessDefinition.getDefinition(ProcessDefinition.java:431)
       at org.jbpm.graph.def.ProcessDefinition.getTaskMgmtDefinition(ProcessDefinition.java:444)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
       at org.jbpm.graph.def.ProcessDefinition_$$_javassist_95.getTaskMgmtDefinition(ProcessDefinition_$$_javassist_95.java)
       at uk.co.iblocks.iflow.web.tree.expansion.JbpmExpansion.getProcessSummary(JbpmExpansion.java:402)
       at uk.co.iblocks.iflow.web.tree.expansion.JbpmExpansion.addTaskNodes(JbpmExpansion.java:129)
       at uk.co.iblocks.iflow.web.tree.expansion.JbpmExpansion$$FastClassByCGLIB$$b998e405.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:37)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:154)
       at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:89)
       at uk.co.iblocks.iflow.web.tree.expansion.JbpmExpansion$$EnhancerByCGLIB$$9eed0613.addTaskNodes(<generated>)
       at uk.co.iblocks.iflow.web.tree.expansion.JbpmExpansion$JbpmType$3.addNodes(JbpmExpansion.java:68)
       at uk.co.iblocks.iflow.web.tree.expansion.JbpmExpansion.addNodes(JbpmExpansion.java:77)
       at uk.co.iblocks.iflow.web.TreeBean.exploreNode(TreeBean.java:270)
       at uk.co.iblocks.iflow.web.tree.TreeData$DebugNodeListener.exploreNode(TreeData.java:59)
       at uk.co.iblocks.iflow.web.tree.TreeData$DebugNodeListener.exploreNode(TreeData.java:59)
       at uk.co.iblocks.iflow.web.tree.TreeData$DebugNodeListener.exploreNode(TreeData.java:59)
       at uk.co.iblocks.iflow.web.tree.TreeData.setExpanded(TreeData.java:414)
       at com.icesoft.faces.component.tree.TreeRenderer.decode(TreeRenderer.java:109)
       at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:500)
       at com.icesoft.faces.component.tree.Tree.processDecodes(Tree.java:857)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:53)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:602)
       at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:135)
       at org.apache.myfaces.lifecycle.LifecycleImpl.applyRequestValues(LifecycleImpl.java:219)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:71)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCyclePartial(BlockingServlet.java:473)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(BlockingServlet.java:442)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.executeRequest(BlockingServlet.java:324)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:186)
       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.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:393)
       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: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:619)
      


        • 1. Re: jBPM and LIE
          Joshua Jackson Master

          Shouldn't you be asking this in jBPM sub-forum?

          • 2. Re: jBPM and LIE
            Peter Brewer Novice

            Thanks for the tip, is there a jBPM sub-forum of the Seam forum? I can't find a link to it :(

            I thought it was more relevant to the Seam forum than the jBPM forum as my question is more about how to access jBPM database objects through Seam in a conversation safe manner. Perhaps I wasn't clear in my original post...

            I obtain a hibernate Session, capable of querying jBPM entities:

             @In
             private JbpmContext jbpmContext ;
            ...
             Session hibernateSession = jbpmContext.getSession() ;
            


            but this session does not remain active for the duration of the Seam conversation (like a Seam Managed Persistence Context would) - so I get a LIE.

            My question is really: Can I access jBPM entites using a SMPC? If so, how do I configure it? If not, are there any alternatives/ workarounds.

            Thanks in advance, Pete.