I have tomcat with shared process engine, a application UI war an a seperate process war which contains bmpn and java delegates.
UI adds a json process variable when a user task is completed:
ObjectValue serializedProtocol = Variables.objectValue(receiveProtocol).serializationDataFormat("application/json").create();
variables.put("receiveProtocol", serializedProtocol);
taskService.complete(task.getId(), variables);
Next step is a service task, here we get a ClassCastException: xxx.ReceiveProtocol cannot be cast to xxx.ReceiveProtocol
when calling
ReceiveProtocol rp = (ReceiveProtocol) exe.getVariable("receiveProtocol");
When I replace this with:
ObjectValue ov = exe.getVariableTyped("receiveProtocol");
ReceiveProtocol rp = JSON(ov.getValueSerialized()).mapTo(ReceiveProtocol.class);
it works fine. It also works if I set asynchronous before on the service task.
Perhaps the variable is not deserialized and taken from some cache instead. This would be overoptimized because the classloader which initially created the variable is different from the delegates classloader.