-
1. Re: how to setVariable
salaboy21 Nov 13, 2012 7:03 AM (in response to johennes)Hi,
Where did you use that code?
Did you check that the ksession is not null and the process returned from the getProcessInstnace(processId) is not null?
Cheers
-
2. Re: how to setVariable
johennes Nov 13, 2012 10:41 AM (in response to salaboy21)Ksession and ProcessInstance are not null.
When I use "getVariable()",the result is not null,only the "setVariable()" is the problem.
-
3. Re: how to setVariable
salaboy21 Nov 13, 2012 11:44 AM (in response to johennes)Can you please share the Stacktrace? because if we see the stacktrace we can see where the NullPointerException is happening, if not it can be anywhere.
Cheers
-
4. Re: how to setVariable
jdantas9 Nov 13, 2012 2:36 PM (in response to johennes)I have the same problem, but in my case, when I use "setVariable()", process and kruntime are null. I'm using the version 5.2. Look at my stacktrace:
java.lang.NullPointerException: null
at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67) ~[jbpm-flow-5.2.0.Final.jar:5.2.0.Final]
at org.jbpm.process.instance.impl.ProcessInstanceImpl.getContextInstance(ProcessInstanceImpl.java:127) ~[jbpm-flow-5.2.0.Final.jar:5.2.0.Final]
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setVariable(WorkflowProcessInstanceImpl.java:238) ~[jbpm-flow-5.2.0.Final.jar:5.2.0.Final]
Thanks.
-
5. Re: how to setVariable
jdantas9 Nov 13, 2012 2:43 PM (in response to johennes)I've forgotten to comment that I'm using jbpm into Weblogic 11g. Can it be a problem?
-
6. Re: how to setVariable
johennes Nov 13, 2012 7:44 PM (in response to johennes)I use TOMCAT6(this cannot be changed)+MYSQL+JBPM5.3
my stacktrace:
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:238)
it is the same of Juliano Dantas's
-
7. Re: how to setVariable
johennes Nov 13, 2012 7:47 PM (in response to johennes)And my code :
HornetQHTWorkItemHandler hornetQHTWorkItemHandler = new HornetQHTWorkItemHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", hornetQHTWorkItemHandler);
WorkflowProcessInstanceImpl pi = (WorkflowProcessInstanceImpl)ksession.getProcessInstance(processid);
pi.setVariable(param, values);
-
8. Re: how to setVariable
jdantas9 Nov 19, 2012 11:38 AM (in response to johennes)I think this can help you:
public void setVariable(Long processInstanceId, String nome, Object value) {
TransactionManager transactionManager = jBpmConfiguration.getTransactionManager();
try {
transactionManager.begin();
RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) JBpmConfiguration.getInstance().getKnowledgeSession().getProcessInstance(processInstanceId);
processInstance.setVariable(nome, value);
transactionManager.commit();
} catch (Exception e) {
logger.error(e.getMessage());
}
}
-
9. Re: how to setVariable
johennes Nov 19, 2012 8:16 PM (in response to jdantas9)Thanks, I have got the solution what is the same with yours.It really caused by the Transaction.