[jboss-user] [jBPM] - ProcessContext Throwing NPE

roxy1987 do-not-reply at jboss.com
Thu Mar 7 11:04:33 EST 2013


roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"ProcessContext Throwing NPE"

To view the discussion, visit: https://community.jboss.org/message/801365#801365

--------------------------------------------------------------
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
[https://community.jboss.org/message/801365#801365]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130307/15a63eb9/attachment.html 


More information about the jboss-user mailing list