cancel
Showing results for 
Search instead for 
Did you mean: 

HistoricDetailVariableInstanceUpdateEntity can not deserialize value using custom ClassLoader

smokemaker
Champ in-the-making
Champ in-the-making
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:

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


In org.alfresco.repo.workflow.activiti.properties.ActivitiPropertyConverter.convertHistoricDetails
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!

Serge
4 REPLIES 4

trademak
Star Contributor
Star Contributor
That looks like a bug indeed. I think the best place to raise the issue would be with Alfresco (community or enterprise).

Best regards,

smokemaker
Champ in-the-making
Champ in-the-making
Tijs, thanks for your reply!

But do you think the Alfresco code should be modified? It seems that Alfresco just uses the Activiti API via HistoryService. Or do they use it in improper way?

Thank you!

Serge

jbarrez
Star Contributor
Star Contributor
The Alfresco integration is in a very particular way implemented. That's why Tijs pointed out it's rather on the Alfresco side.

frederikherema1
Star Contributor
Star Contributor
This is already fixed in current Activiti-releases, having all serialisable variables touched (value cached in the variable instance) before leaving the command-context, when getting them. Unfortunately, this fix is not yet part of the current Alfresco release.

This can be fixed in the Alfresco code as well, IMHO. So best to create an issue, as Tijs suggested.