Error on create Process Instance Modification in a multiinstance task

Hello,
we are trying createProcessInstanceModification in version 7.3 and gets this error:
Error message: activityInstance is null at org.camunda.bpm.engine.exception.NullValueException: activityInstance is null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:283)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:44)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:39)
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:31)
at org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand.getScopeExecutionForActivityInstance(AbstractProcessInstanceModificationCommand.java:103)
at org.camunda.bpm.engine.impl.cmd.ActivityInstanceCancellationCmd.determineSourceInstanceExecution(ActivityInstanceCancellationCmd.java:49)
at org.camunda.bpm.engine.impl.cmd.AbstractInstanceCancellationCmd.execute(AbstractInstanceCancellationCmd.java:33)
at org.camunda.bpm.engine.impl.cmd.AbstractInstanceCancellationCmd.execute(AbstractInstanceCancellationCmd.java:26)
at org.camunda.bpm.engine.impl.cmd.ModifyProcessInstanceCmd.execute(ModifyProcessInstanceCmd.java:52)
at org.camunda.bpm.engine.impl.cmd.ModifyProcessInstanceCmd.execute(ModifyProcessInstanceCmd.java:30)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:97)
at org.camunda.bpm.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:59)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
at org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl.execute(ProcessInstanceModificationBuilderImpl.java:219)
at org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl.execute(ProcessInstanceModificationBuilderImpl.java:210)

Our process definition

We need to add an instance to the multiinstance task (Finished individual recruiting) and try this:

List individualRectruitings = …
individualRectruitings.add(recruitingProcessId);
runtimeService.createProcessInstanceModification(processInstanceId)
.startBeforeActivity(“tskRefreshIndividualRecruitings”)
.setVariable(“individualRecruitings”, individualRectruitings)
.cancelAllForActivity(“tskFinishedIndividualRecruiting”)
.execute();

Thanks in advance.

Marcel.

Hi Marcel,

Could you try to reproduce the issue with more recent Camunda version - 7.8 or 7.9-alpha
Also I think you need to fix your process:
image
The service task “Refresh…” is not reachable.

Best regards,
Yana

Hi Yana,
I will test with 7.8 version and comment the result.

The “Refresh ind…” task is not reachable because for me is not a real task, i only need it to call .startBeforeActivity(“tskRefreshIndividualRecruitings”) with diferent taskId than “tskFinishedIndividualRecruiting”

Do we have another posibility?

If I use this
runtimeService.createProcessInstanceModification(processInstanceId)
.startBeforeActivity(“tskFinishedIndividualRecruiting”)
.setVariable(“individualRecruitings”, individualRectruitings)
.cancelAllForActivity(“tskFinishedIndividualRecruiting”)
.execute();

the process instance desapears.

Marcel.

Hi,
after migrate version to 7.8 on jBoss environment, in jboss log appear this:

ERROR ENGINE-03068 No deployment lock property found in databse
In ACT_GE_PROPERTY we have this records
NAME VALUE_ REV_
history.cleanup.job.lock 0 1
historyLevel 2 1
startup.lock 0 1

What should we do?

Thanks

Strange, this property should be there since Camunda 7.2.

-- add deployment.lock row to property table --
INSERT INTO ACT_GE_PROPERTY                    
  VALUES ('deployment.lock', '0', 1);          

Hi,

Did you execute the db upgrade scripts?

Otherwise please provide the complete stack trace.

Best regards,
Yana

Thanks to both of you.
It was my mistake in the execution of the scripts.

Regarding the initial problem, with version 7.8 with the process instance in task Finished individual recruiting as you can see in the image

after executing the following instructions, there is no error but the process disappears in cockpit

…
individualRectruitings.add(recruitingProcessId);
runtimeService.createProcessInstanceModification(“66be972a-5e93-11e8-96df20524153”)
.startBeforeActivity(“tskRefreshIndividualRecruitings”)
.setVariable(“individualRecruitings”, individualRectruitings)
.cancelAllForActivity(“tskFinishedIndividualRecruiting”)
.execute();

I’ve verified it with a query from cockpit and gets this warning in the log

WARNING [ExceptionHandler] (http-/0.0.0.0:8080-1) org.camunda.bpm.engine.rest.exception.InvalidRequestException: Process instance with id 66be972a-5e93-11e8-847e-96df20524153 does not exist

What can I do to increase the number of executions for an instance in the multiinstance task (Finished individual recruiting)?

Best regards.
Marcel.

Why do you do this?

.cancelAllForActivity(“tskFinishedIndividualRecruiting”)

Edit:

Or stated differently, doesn’t this simply work?

runtimeService.createProcessInstanceModification(“66be972a-5e93-11e8-96df20524153”)
.startBeforeActivity(“tskFinishedIndividualRecruiting”)
.setVariableLocal(“elementVariable”, elementValue)
.execute();

Thanks thorben,
it works as you say without .cancelAllForActivity!!!

Can you explain to me why it should be like this?
I have tried createProcessInstanceModification from users tasks “Edit Affiliation” and “Correct…” and vice versa and it works correctly with the .cancelAllForActivity.
And in the documentation it is not clear to me when to use the .cancellAll because all the examples have it.
https://docs.camunda.org/manual/7.8/user-guide/process-engine/process-instance-modification/

Kind regards
Marcel.

Hi Marcel,

I’ll try to explain what the previous modification did. Let’s assume we have 3 instances in tskFinishedIndividualRecruiting and the following modification:

runtimeService.createProcessInstanceModification(“66be972a-5e93-11e8-96df20524153”)
.startBeforeActivity(“tskRefreshIndividualRecruitings”)
.cancelAllForActivity(“tskFinishedIndividualRecruiting”)
.execute();

Instructions are executed in the order you submit them. That means, the process engine will first perform the startBefore instruction and run until the next wait state (as usual). Let’s assume this creates 3 new instances of tskFinishedIndividualRecruiting because the multi-instance cardinality is 3. Now, the engine performs the cancelAllForActivity instruction so it cancels all six instances of tskFinishedIndividualRecruiting including the ones we just started. See also this docs section on this topic: https://docs.camunda.org/manual/7.8/user-guide/process-engine/process-instance-modification/#instruction-execution-order

If you wanted to cancel only those three that existed before we apply the modification, you could use the cancelActivityInstance instruction (see https://docs.camunda.org/manual/7.8/user-guide/process-engine/process-instance-modification/#cancel-an-activity-instance) to select exactly the activity instances to cancel.

edit: As a rule of thumb,

this

runtimeService.createProcessInstanceModification(“66be972a-5e93-11e8-96df20524153”)
.startBeforeActivity(“tskRefreshIndividualRecruitings”)
.cancelAllForActivity(“tskFinishedIndividualRecruiting”)
.execute();

is equivalent to this

runtimeService.createProcessInstanceModification(“66be972a-5e93-11e8-96df20524153”)
.startBeforeActivity(“tskRefreshIndividualRecruitings”)
.execute();

runtimeService.createProcessInstanceModification(“66be972a-5e93-11e8-96df20524153”)
.cancelAllForActivity(“tskFinishedIndividualRecruiting”)
.execute();

if we ignore that the latter example creates two separate transactions.

1 Like

HI Thorben,

Thank you very much for the excellent explanation, now it is perfectly clear to me.
I did not have the order of execution in mind.

King regards.

Marcel.

Hi,
I have done more tests and I have detected a problem.

I have a process with 9 execution instances in the multiinstance task before executing .createProcessInstanceModification
PreviousVariables

After adding an element to the collection and running .createProcessInstanceModification
a new execution is generated, the nrOfInstances and nrOfActiveInstances variables are increased but an individual PayrollProcessId is missing in the process variables.
There are 10 loopCounter values with values 0 to 9
But there are only 9 individualPayrollProcessId values
AfterVariables

If i read que individualPayrollProcessId variable for all the 10 executions, is there one with null value.

Thanks.

Marcel.

Hi Marcel,

That is expected behavior. You have to set the element variable manually, for example by adding a #setVariableLocal call to the startBefore instruction.

Cheers,
Thorben

Many thanks Thorben.

I think i finally have it.

Marcel.

1 Like