AnsweredAssumed Answered

HistoricDetailVariableInstanceUpdateEntity can not deserialize value using custom ClassLoader

Question asked by smokemaker on Jul 14, 2014
Latest reply on Jul 21, 2014 by smokemaker
Hi all!

Help me, please, with custom ClassLoader in ProcessEngineConfigurationImpl
The issue can be seen on Activiti 5.13 under Alfresco.

In org.alfresco.repo.workflow.activiti.ActivitiWorkflowEngine.endNormalTask:

// The task should have a historicTaskInstance
HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
return typeConverter.convert(historicTask); // <— The problem is here

we see the instructions:

for(Entry<String, HistoricVariableUpdate> entry : updateMap.entrySet())
      variables.put(entry.getKey(), entry.getValue().getValue());

when trying to getValue in org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity
we come to org.activiti.engine.impl.variable.SerializableType.getValue

and then - to org.activiti.engine.impl.util.ReflectUtil.loadClass:
   Class<?> clazz = null;
   ClassLoader classLoader = getCustomClassLoader();

in getCustomClassLoader():
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    if(processEngineConfiguration != null) {
      final ClassLoader classLoader = processEngineConfiguration.getClassLoader();
      if(classLoader != null) {
        return classLoader;
    return null;

at this point we can see that Context.getProcessEngineConfiguration() returns null (it's always cleared by executed commands in the end of execution).

So, we can not use custom ClassLoader, added to ProcessEngineConfigurationImpl, and of course get an java.lang.ClassNotFoundException.

The question is: isn't it a bug, and if not then how to deal with this behavior?

Thank you!