Hello,
Thank you for the link. Indeed, when I don't use persistence I just used the workflowProcessInstance and it works great. And the NullPointerException apear after changing to persistent session.
But, I already try the command base approach and in my case it doesn't change anything.
My conclusion that seams to work for now is :
WorkflowProcessInstance wpi = (WorkflowProcessInstance)kSession.getProcessInstance(processInstanceId);
wpi.getVariable(key);
to access variables even if I use persistent session.
and define output parameters mapped to process variables directly inside the process and pass a map of results to the complete task method to dynamically change process variables.