AnsweredAssumed Answered

How to query all tasks of a given workflow instance? (NPE)

Question asked by nicolasraoul on Feb 22, 2010
Latest reply on Apr 23, 2010 by nicolasraoul
I want to get the list of tasks of a given workflow instance. So I wrote:

WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setProcessId("jbpm$" + new Long(processInstance.getId()).toString());
query.setTaskState(WorkflowTaskState.COMPLETED); // TODO add those IN_PROGRESS
List<WorkflowTask> tasks = workflowService.queryTasks(query);

But it already gives an exception:

ERROR [org.jbpm.graph.def.GraphElement] action threw exception: null
java.lang.NullPointerException
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowNode(JBPMEngine.java:2699)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowPath(JBPMEngine.java:2685)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowTask(JBPMEngine.java:2841)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.getWorkflowTasks(JBPMEngine.java:1289)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$24.doInJbpm(JBPMEngine.java:1260)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$24.doInJbpm(JBPMEngine.java:1249)
   at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.queryTasks(JBPMEngine.java:1247)
   at org.alfresco.repo.workflow.WorkflowServiceImpl.queryTasks(WorkflowServiceImpl.java:522)
   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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:148)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy46.queryTasks(Unknown Source)
   at org.myproject.EndActionHandler.readHistory(EndActionHandler.java:80)

If I comment the setTaskState line, then no exception but empty result. Any idea what is happening?

What would be a valid way to get the list of tasks for a given workflow instance?

Thanks a lot!
Nicolas

Outcomes