Receive Task inside a Sub Process

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

Receive Task inside a Sub Process

Jump to solution

I have a BPM which has a receive task inside a sub process.

When I try to signal the process instance execution after creation i get the following error :

java.lang.NullPointerException
    at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:406)
    at org.activiti.engine.impl.cmd.SignalCmd.execute(SignalCmd.java:43)
    at org.activiti.engine.impl.cmd.NeedsActiveExecutionCmd.execute(NeedsActiveExecutionCmd.java:55)
    at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
    at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
    at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
    at org.activiti.engine.impl.RuntimeServiceImpl.signal(RuntimeServiceImpl.java:231)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I have attached the BPMN : PNG and the XML(BPMN20)

Here is the process XML :

<process id="Basic_receive_task" name="BasicReceiveTask" isExecutable="true">
    <subProcess id="sub_process" name="sub process">
      <receiveTask id="receive_task" name="Receive Task"></receiveTask>
      <startEvent id="start_sub_process" name="start sub process"></startEvent>
      <endEvent id="end_sub_process" name="end sub process"></endEvent>
      <sequenceFlow id="to_receive_task" name="to receive task" sourceRef="start_sub_process" targetRef="receive_task"></sequenceFlow>
      <sequenceFlow id="from_receive_task" name="from receive task" sourceRef="receive_task" targetRef="end_sub_process"></sequenceFlow>
    </subProcess>
    <startEvent id="start_process" name="start process"></startEvent>
    <endEvent id="end_process" name="end process"></endEvent>
    <sequenceFlow id="sid-DDE7998A-D99D-4A4E-BFAA-3BC6CF33E6BB" sourceRef="sub_process" targetRef="end_process"></sequenceFlow>
    <sequenceFlow id="to_sub_process" name="to sub process" sourceRef="start_process" targetRef="sub_process"></sequenceFlow>
</process>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Am I missing something?

Please advice.

Thanks.

EDIT 1 (Junit):

@Test
public void test() {
     //initialize activiti engine
     RuntimeService runtimeService = activitiRule.getRuntimeService();
    
     //create WF
     ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Basic_receive_task", "TEST");

     runtimeService.signal(processInstance.getId());

}‍‍‍‍‍‍‍‍‍‍‍
1 Solution

Accepted Solutions
Highlighted
Intermediate

Re: Receive Task inside a Sub Process

Jump to solution

Ok, so the devil is always in the detail.

You are signalling the process instance ID which in this case is not likely to be the same as the execution ID, hence the NPE.

You will need to retrieve the execution ID by querying the engine for the receive task, then use that ID rather than the process instance id.

Cheers,

Greg

View solution in original post

4 Replies
Highlighted
Intermediate

Re: Receive Task inside a Sub Process

Jump to solution

How are you "signalling" the Receive Task?

Please provide a unit test demonstrating what you are seeing.

Greg

Highlighted
Member II

Re: Receive Task inside a Sub Process

Jump to solution

Thanks for the prompt reply.

The Junit is updated at the end of question.

Highlighted
Intermediate

Re: Receive Task inside a Sub Process

Jump to solution

Ok, so the devil is always in the detail.

You are signalling the process instance ID which in this case is not likely to be the same as the execution ID, hence the NPE.

You will need to retrieve the execution ID by querying the engine for the receive task, then use that ID rather than the process instance id.

Cheers,

Greg

View solution in original post

Highlighted
Member II

Re: Receive Task inside a Sub Process

Jump to solution

Thanks a lot Greg!! It works fine now.

For the reference of others, this is the order of usage.

  1. /activiti-rest/service/runtime/process-instances?businessKey=0642

  2. /activiti-rest/service/query/executions [take the parent ID from step 1result]

    {

      "parentId" : "97122075"

    }

  3. /activiti-rest/service/runtime/executions/97122088 [take the execution ID from step 2 result]

    {

    "action":"signal"

    }