NPE on variables get from ProcessInstance loaded via ProcessInstanceQuery
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2013 06:49 AM
Hello Activiti developers,
While executing in Activiti 5.13<java start="488" fancy="6"> ProcessInstance process = runtimeService.createProcessInstanceQuery()
.processInstanceId( "1234" )
.includeProcessVariables()
.singleResult();
if( process != null ) {
Map<String, Object> vars = process.getProcessVariables(); //Throws NPE in ByteArrayRef.java:94
…
}</java>I observe the following error
I tried to debug and found that
A similar code that passes the same row (
.processInstanceId( "1234" )
.list();
if( executions != null ) {
for (Execution execution : executions) {
Map<String, Object> globalVars = runtimeService.getVariables( execution.getId() );
if( globalVars != null ) {
…
}
}
}</java>
Am I doing something wrong?
While executing in Activiti 5.13<java start="488" fancy="6"> ProcessInstance process = runtimeService.createProcessInstanceQuery()
.processInstanceId( "1234" )
.includeProcessVariables()
.singleResult();
if( process != null ) {
Map<String, Object> vars = process.getProcessVariables(); //Throws NPE in ByteArrayRef.java:94
…
}</java>I observe the following error
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.VariableInstanceEntity.getBytes(VariableInstanceEntity.java:138) 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.VariableInstanceEntity.getValue(VariableInstanceEntity.java:165) at org.activiti.engine.impl.persistence.entity.ExecutionEntity.getProcessVariables(ExecutionEntity.java:1384) at org.activiti.engine.impl.ant.ShowProcessState.formatProcessInstance(ShowProcessState.java:493)…‍‍‍‍‍‍‍‍‍‍
I tried to debug and found that
Context.getCommandContext()‍
returns null‍
in ByteArrayRef.java:94‍
.A similar code that passes the same row (
ByteArrayRef.java:94‍
) runs fine:<java start="488" fancy="6"> List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId( "1234" )
.list();
if( executions != null ) {
for (Execution execution : executions) {
Map<String, Object> globalVars = runtimeService.getVariables( execution.getId() );
if( globalVars != null ) {
…
}
}
}</java>
Am I doing something wrong?
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2013 01:15 AM
Hello,
Isn't there anyone to comment on the above?
Isn't there anyone to comment on the above?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2013 04:59 AM
Thanks for reporting. Issue has just been fixed on master:
https://jira.codehaus.org/browse/ACT-1731 and https://github.com/Activiti/Activiti/commit/136859b6e4100d80c34bfc5c43964c8c8e4362de.
https://jira.codehaus.org/browse/ACT-1731 and https://github.com/Activiti/Activiti/commit/136859b6e4100d80c34bfc5c43964c8c8e4362de.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2015 01:58 AM
In case someone wants to follow the github link above (it shouldn't have the trailing ".") click this link instead:
https://github.com/Activiti/Activiti/commit/136859b6e4100d80c34bfc5c43964c8c8e4362de
https://github.com/Activiti/Activiti/commit/136859b6e4100d80c34bfc5c43964c8c8e4362de
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2013 06:21 AM
Thank you, Frederik! 🙂
I'm glad I helped somehow.
I'm glad I helped somehow.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2013 05:01 AM
I have more or less the same bug in version 5.13 of the REST API, where you do not get the variables on the list of processes.
Works on list of task as expected:
/runtime/tasks?includeProcessVariables = true
Does not work on list of process:
/runtime/process-instances?includeProcessVariables = true
Where you only get blank values ​​"variables": []
Will this error be corrected with the other issue or should this issue be reported separately ?
Works on list of task as expected:
/runtime/tasks?includeProcessVariables = true
Does not work on list of process:
/runtime/process-instances?includeProcessVariables = true
Where you only get blank values ​​"variables": []
Will this error be corrected with the other issue or should this issue be reported separately ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2013 08:32 AM
Should be reported separately, as it's not an exception that is occurring but rather something not working as expected…

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2013 10:05 AM
First of all sorry for my english
.
We use version 5.13 and to get list of HistoricVariableInstance we wanted to use NativeHistoricVariableInstanceQuery.
<code>
public List<HistoricVariableInstance> listHistoricVariableInstances(String processInstanceId, Collection<String> variableNames) {
..
StringBuilder query = new StringBuilder();
query.append("select * from ");
query.append(managementService.getTableName(HistoricVariableInstance.class));
query.append(" where proc_inst_id_ = #{proc_inst_id} and name_ in (");
query.append(ActivitiUtils.createInSet(variableNames));
query.append(")");
return historyService.createNativeHistoricVariableInstanceQuery().sql(query.toString()).parameter("proc_inst_id", processInstanceId).list();
}
</code>
But when we invoke "HistoricVariableInstance#getValue()",
<code>
private void mapVarList(List<HistoricVariableInstance> historicVariableInstances, Map<String, UserLoopResponses> varMap) {
if (historicVariableInstances == null || historicVariableInstances.isEmpty()) {
return;
}
for (HistoricVariableInstance hiVariable : historicVariableInstances) {
Object value = hiVariable.getValue();//This line throws npe
if (value == null || !(value instanceof UserLoopResponses)) {
continue;
}
varMap.put(hiVariable.getVariableName(), (UserLoopResponses) value);
}
}
</code>
we get :
<code>
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)
</code>
Historic value is serializable type. Now my question, is this is the same bug (i tried on version 5.14 but still that same) or i can't get serializable value by nativequery
(i'm beginer at activiti so i may have probably doing something silly
)?

We use version 5.13 and to get list of HistoricVariableInstance we wanted to use NativeHistoricVariableInstanceQuery.
<code>
public List<HistoricVariableInstance> listHistoricVariableInstances(String processInstanceId, Collection<String> variableNames) {
..
StringBuilder query = new StringBuilder();
query.append("select * from ");
query.append(managementService.getTableName(HistoricVariableInstance.class));
query.append(" where proc_inst_id_ = #{proc_inst_id} and name_ in (");
query.append(ActivitiUtils.createInSet(variableNames));
query.append(")");
return historyService.createNativeHistoricVariableInstanceQuery().sql(query.toString()).parameter("proc_inst_id", processInstanceId).list();
}
</code>
But when we invoke "HistoricVariableInstance#getValue()",
<code>
private void mapVarList(List<HistoricVariableInstance> historicVariableInstances, Map<String, UserLoopResponses> varMap) {
if (historicVariableInstances == null || historicVariableInstances.isEmpty()) {
return;
}
for (HistoricVariableInstance hiVariable : historicVariableInstances) {
Object value = hiVariable.getValue();//This line throws npe
if (value == null || !(value instanceof UserLoopResponses)) {
continue;
}
varMap.put(hiVariable.getVariableName(), (UserLoopResponses) value);
}
}
</code>
we get :
<code>
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)
</code>
Historic value is serializable type. Now my question, is this is the same bug (i tried on version 5.14 but still that same) or i can't get serializable value by nativequery
(i'm beginer at activiti so i may have probably doing something silly


Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2013 10:15 AM
The query that you are performing can also be done via the standard Activiti API.
It was a bug in 5.13, but it should be working in 5.14. Could you create a JIRA issue with a unit test showing the issue?
Best regards,
It was a bug in 5.13, but it should be working in 5.14. Could you create a JIRA issue with a unit test showing the issue?
Best regards,
