[jboss-user] [jBPM] - How to setVariable after JPAKnowledgeService.loadStatefulKnowledgeSession
Jack Q tao
do-not-reply at jboss.com
Thu Nov 17 03:39:15 EST 2011
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&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111117/f012eb1d/attachment-0001.html
More information about the jboss-user
mailing list