Jack Q tao [
http://community.jboss.org/people/qintao1203] created the discussion
"How to setVariable after JPAKnowledgeService.loadStatefulKnowledgeSession"
To view the discussion, visit:
http://community.jboss.org/message/636928#636928
--------------------------------------------------------------
Hi all,
I write some code to change variables of process , but it can't work .
The error info:
java.lang.NullPointerException
at
org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67)
at
org.jbpm.process.instance.impl.ProcessInstanceImpl.getContextInstance(ProcessInstanceImpl.java:127)
at
org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setVariable(WorkflowProcessInstanceImpl.java:237)
My code :
KnowledgeBase kbase = createKnowledgeBase();
StatefulKnowledgeSession ksession
=JPAKnowledgeService.loadStatefulKnowledgeSession(jbpm.getSessionId(), kbase, null,
getEnv() );
CommanWSHumanTaskHandler humanTaskHandler = new
CommanWSHumanTaskHandler(ksession);
humanTaskHandler.setClient(taskClientWrapper.getTaskClient());
humanTaskHandler.setSessionId(ksession.getId());
ksession.getWorkItemManager().registerWorkItemHandler("Human
Task", humanTaskHandler);
humanTaskHandler.connect();
ProcessInstance pi = ksession.getProcessInstance(jbpm.getProcessId());
Boolean isSign = (Boolean)
((WorkflowProcessInstance)pi).getVariable("isSign");
List<String> list = (List<String>)
((WorkflowProcessInstance)pi).getVariable("signers"); // *isSign* and *list*
are not null*.*
((WorkflowProcessInstance)pi).setVariable("isSign",
true); // throws exception
((WorkflowProcessInstance)pi).setVariable("signers",
signers);
ksession.insert(pi);
I don't understand why. and How to fix it.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/636928#636928]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]