Hi,
I have migrated from Activiti 5.21 to Flowable 6.3. After migrating, the new definitions and their instances work fine but for the old definitions when I launch the process instance I get the following error in the event listener.
e.common.impl.event.FlowableEventSupport - Exception while executing event-listener, which was ignored
java.lang.ClassCastException: org.activiti.engine.impl.persistence.entity.TaskEntity cannot be cast to org.flowable.task.service.impl.persistence.entity.TaskEntity
My code is as follows in listner -
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
…
…
…
case TASK_CREATED:
FlowableEntityEvent taskEvent = (FlowableEntityEvent) e;
TaskEntity entity = (TaskEntity) taskEvent.getEntity();
processDefinitionKey = entity.getTaskDefinitionKey(); …
If I change the code to following it works
case TASK_CREATED:
if (taskEvent.getEntity() instanceof TaskEntity) {
TaskEntity entity = (TaskEntity) taskEvent.getEntity();
processDefinitionKey = entity.getTaskDefinitionKey();
}else{
processDefinitionKey = ((org.activiti.engine.impl.persistence.entity.TaskEntity)
taskEvent.getEntity()).getTaskDefinitionKey()
}
Is this the correct way of handling the event ? Do We have to handle the backward compatibility in our code like above ?