We're updating the issue view to help you get more done. 

Process Instance execution gives error when transient variables are set

Description

When a process instance is created without transient variables it works fine but as soon as I add transient variables, it gives error, on further investigations it was found that this happens only when process ends with all transient nodes in path with which it directly ends. Attached a very simple process to reproduce it.

below is function with relevant code:

public static ProcessInstance startProcessInstance(String pdId, String instanceKey,
Map<String, Object> processVariables,
Map<String, Object> transientVariables) {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstanceBuilder builder = runtimeService.createProcessInstanceBuilder()
.processDefinitionKey(pdId)
.businessKey(instanceKey);
if(processVariables!=null) {
builder.variables(processVariables);
}
if(transientVariables!=null) {
builder.transientVariables(transientVariables);
}
ProcessInstance processInstance = builder.start();
System.out.println("Created process instance with business key "instanceKey" using process definition "pdId" version "+processInstance.getProcessDefinitionVersion());
return processInstance;
}

Stack Trace is as below:
16:20:59,059 CommandContext.java:122 Error while closing command context
java.lang.ClassCastException: org.activiti.engine.impl.persistence.entity.TransientVariableInstance cannot be cast to org.activiti.engine.impl.persistence.entity.VariableInstanceEntity
at org.activiti.engine.impl.persistence.entity.ExecutionEntityManagerImpl.deleteDataForExecution(ExecutionEntityManagerImpl.java:569)
at org.activiti.engine.impl.persistence.entity.ExecutionEntityManagerImpl.deleteExecutionAndRelatedData(ExecutionEntityManagerImpl.java:422)
at org.activiti.engine.impl.persistence.entity.ExecutionEntityManagerImpl.deleteProcessInstanceExecutionEntity(ExecutionEntityManagerImpl.java:455)
at org.activiti.engine.impl.agenda.EndExecutionOperation.handleProcessInstanceExecution(EndExecutionOperation.java:81)
at org.activiti.engine.impl.agenda.EndExecutionOperation.handleRegularExecution(EndExecutionOperation.java:166)
at org.activiti.engine.impl.agenda.EndExecutionOperation.run(EndExecutionOperation.java:48)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:73)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:57)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:42)
at org.activiti.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:48)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:63)

Environment

None

Status

Assignee

Unassigned

Reporter

Shailesh Tamboli

Labels

Components

Affects versions

6.0

Priority

Highest