JBoss Community

ProcessContext Throwing NPE

created by roxy1987 in jBPM - View the full discussion

Hi community,

 

I have run into an issue trying to set a variable.

What I want is to set a variable while completing a task. The following is what I do :

 

 

//Just before task complete I call the following code.
 
StatefulKnowledgeSession kSession = BpmRepositoryConfig.createSession();
  ProcessContext kContext = new ProcessContext(kSession);
  ProcessInstance processInstance = kSession.getProcessInstance(taskData.getProcessInstanceId());
  logger.info("ProcInst : "+processInstance.getId());
  kContext.setProcessInstance(processInstance);
  for (Entry<String, Object> entry : map.entrySet())
  {
      logger.info(entry.getKey() + "/" + entry.getValue());
      if(!(kContext == null))
       kContext.setVariable(entry.getKey(), entry.getValue());
      else
       logger.severe("KContext is Null");
  }
 

 

KContext is not null. But it throws the following NPE :

 

 

[3/7/13 10:47:46:951 COT] 00000110 SystemErr     R java.lang.NullPointerException
[3/7/13 10:47:46:951 COT] 00000110 SystemErr     R  at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:68)
[3/7/13 10:47:46:951 COT] 00000110 SystemErr     R  at org.jbpm.process.instance.impl.ProcessInstanceImpl.getContextInstance(ProcessInstanceImpl.java:133)
[3/7/13 10:47:46:951 COT] 00000110 SystemErr     R  at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setVariable(WorkflowProcessInstanceImpl.java:238)
[3/7/13 10:47:46:951 COT] 00000110 SystemErr     R  at org.drools.spi.ProcessContext.setVariable(ProcessContext.java:68)
[3/7/13 10:47:46:951 COT] 00000110 SystemErr     R  at pe.com.bcp.model.BpmAPI.createTaskVariables(Unknown Source)

 

Need help please. And other ideas to create task variables are welcome. Thanks.

Reply to this message by going to Community

Start a new discussion in jBPM at Community