AnsweredAssumed Answered

NPE retrieving a blob local task variable

Question asked by hyapit on Jun 27, 2013
Latest reply on Jul 17, 2013 by frederikheremans1
Hi guys,

I'm getting a NullPointerException executing HistoricTaskInstance.getTaskLocalVariables() when I have a task variables with blobs as their values. This is 5.13

It seems like Context.getCommandContext() returns null, because the context threadlocal is not set for executing thread. Is this expected or a bug? Advice?

Here's the stack trace:
java.lang.NullPointerException
   at org.activiti.engine.impl.persistence.entity.ByteArrayRef.ensureInitialized(ByteArrayRef.java:94)
   at org.activiti.engine.impl.persistence.entity.ByteArrayRef.getBytes(ByteArrayRef.java:45)
   at org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity.getBytes(HistoricVariableInstanceEntity.java:119)
   at org.activiti.engine.impl.variable.ByteArrayType.getValue(ByteArrayType.java:32)
   at org.activiti.engine.impl.variable.SerializableType.getValue(SerializableType.java:51)
   at org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity.getValue(HistoricVariableInstanceEntity.java:110)
   at org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity.getTaskLocalVariables(HistoricTaskInstanceEntity.java:172)

This is where it's throwing NPE:
private void ensureInitialized() {
    if (id != null && entity == null) {
      entity = Context.getCommandContext()
        .getByteArrayEntityManager()
        .findById(id);
      name = entity.getName();
    }
  }

Outcomes