Intermittently facing Null pointer exception on setVariableLocal()

Facing intermittently Null pointer exception while setting the variable in delegateExecution.
delegateExecution.setVariableLocal(“FAILURE_REASON”, “failureReason”);

This happens a few times when two different process instance is running parallel.
Didn’t observe this while running only a single process instance.

java.lang.NullPointerException
	at org.camunda.bpm.engine.impl.history.producer.DefaultHistoryEventProducer.createHistoricVariableEvent(DefaultHistoryEventProducer.java:429)
	at org.camunda.bpm.engine.impl.history.producer.DefaultHistoryEventProducer.createHistoricVariableCreateEvt(DefaultHistoryEventProducer.java:838)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceHistoryListener$1.createHistoryEvent(VariableInstanceHistoryListener.java:42)
	at org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor.processHistoryEvents(HistoryEventProcessor.java:77)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceHistoryListener.onCreate(VariableInstanceHistoryListener.java:39)
	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceHistoryListener.onCreate(VariableInstanceHistoryListener.java:32)
	at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.invokeVariableLifecycleListenersCreate(AbstractVariableScope.java:353)
	at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.invokeVariableLifecycleListenersCreate(AbstractVariableScope.java:347)
	at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.setVariableLocal(AbstractVariableScope.java:342)
	at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.setVariableLocal(AbstractVariableScope.java:381)

Need help here to find the root cause and solution.

@StephanHaarmann @Ingo_Richtsmeier @jonathan.lukas

Hi @Vivek_Korat,

Can you provide us additional information?

  • Which version of Camunda 7 are you running?
  • Where are you setting the local variable? For what purpose?
  • An example to reproduce the error?
1 Like
  • camunda version :
<dependency>
      <groupId>com.camunda.consulting</groupId>
      <artifactId>springboot-customized-webapp-webjar</artifactId>
       <version>7.16.0</version>
</dependency>
  • setting variable in execute() method. to fetch from the history again at the end of the workflow execution.
  • observed while running two process instances of the same workflow parallel.

any updates.?

Hi @Vivek_Korat,
Sorry for the delayed response.

Unfortunately, I failed to replicate the issue.
I used the same Camunda version and built a simple process:


Even if I run multiple instances of this process concurrently, everything works out fine.

Do you always receive this exception?
Can you provide additional information, such as the process, the configuration of the Camunda engine, and the delegates?