Rajesh,
What I do is, rather than using completeWithResults(), I complete the task and set the variables like following :
public void setProcessVariables(final long intProcessInstId, final Map<String, Object> hshVariableMap)
{
StatefulKnowledgeSession objKSession = BpmRepositoryConfig.createSession(); //Get the session.
try {
objKSession.execute(new GenericCommand<Map<String, Object>>() {
public Map<String, Object> execute(Context objContext) {
StatefulKnowledgeSession objKSession = ((KnowledgeCommandContext) objContext).
getStatefulKnowledgesession();
org.jbpm.process.instance.ProcessInstance objProcessInstance = (org.jbpm.process.instance.
ProcessInstance) objKSession.
getProcessInstance(intProcessInstId);
VariableScopeInstance objVariableScope = (VariableScopeInstance) objProcessInstance.
getContextInstance(VariableScope.VARIABLE_SCOPE);
Iterator<Map.Entry<String, Object>> objIterator = hshVariableMap.entrySet().iterator();
while(objIterator.hasNext()) {
Map.Entry<String, Object> objPairs = (Map.Entry<String, Object>)objIterator.next();
objVariableScope.setVariable(objPairs.getKey(), objPairs.getValue());
}
return null;
}
});
} catch(Exception objException) {
objLogger.loggerError(objException);
}
}