无法在子流程中定义的活动处启动beforeActivity

时间:2019-05-23 16:38:36

标签: camunda

我有一个父进程,其中子进程以“ callActivity”开始。子进程包含两个任务,task1和task2。当我尝试在“ task1”或“ task2”处启动parentProcess时,出现了NotValidException:

org.camunda.bpm.engine.exception.NotValidException: Element 'task2' does not exist in process parentProcess:1:324: targetElement is null
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:380)
    at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:54)
    at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceAtActivitiesCmd.determineFirstActivity(StartProcessInstanceAtActivitiesCmd.java:123)
    at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceAtActivitiesCmd.execute(StartProcessInstanceAtActivitiesCmd.java:69)
    at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceAtActivitiesCmd.execute(StartProcessInstanceAtActivitiesCmd.java:46)
    at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:27)
    at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:106)
    at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:69)
    at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
    at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.executeWithVariablesInReturn(ProcessInstantiationBuilderImpl.java:165)
    at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.execute(ProcessInstantiationBuilderImpl.java:131)
    at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.execute(ProcessInstantiationBuilderImpl.java:127)

这是我尝试在“ task2”处启动该过程的方法。

runtimeService.createProcessInstanceByKey("parentProcess")
    .startBeforeActivity("task2")
    .execute()

要稍微了解一下上下文:我们需要将旧流程实例迁移到新定义中,因此我们需要能够从流程中的任何用户任务开始。

我想念什么?

1 个答案:

答案 0 :(得分:0)

如果我正确地阅读了您的问题,则可能是您试图在仅对(子)子流程定义有效的步骤上启动父流程定义的实例。正确吗?

如果是这样,那么您看到的行为就是预期的行为,您需要在父流程定义中指定一个活动。

在父实例中遇到子流程调用后,您可以利用某些选项在特定步骤启动子流程实例,但是调用活动不支持该选项,因此需要通过Java API调用进行操作,可以在服务任务或脚本任务中完成。