-
1. Re: calling the setVariable on reloaded ProcessInstance leads to NullPointerException
amadets Mar 4, 2013 6:12 AM (in response to obon)I don't know that is a bug or not, but this not work properly.
Try this:
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.add(varName, varValue);
org.drools.runtime.process.ProcessInstance processInstance = ksession.createProcessInstance(processId, parameters);
ksession.startProcessInstance(processInstance.getId());
WorkflowProcessInstance wpi = (WorkflowProcessInstance) processInstance;
ts
-
2. Re: calling the setVariable on reloaded ProcessInstance leads to NullPointerException
obon Mar 4, 2013 6:21 AM (in response to amadets)Thanks for the answer, but what you suggest is what I do to START a new process instance, but in my case I already have an existing prosess instance persisted in the database.
ButI am trying to RELOAD it, using the above mentioned API ( ksession.getProcessInstance(processInstanceId) ).
The kruntime field of ProcessInstanceImpl is for some reason declared transient, probably therefore it does not get initialized.
Why?
-
3. Re: calling the setVariable on reloaded ProcessInstance leads to NullPointerException
amadets Mar 4, 2013 6:48 AM (in response to obon)ops, sorry i read carelessly.
it may be helpful:
docuemntation said:
Returns the process instance with the given id. Note that only active process instances will be returned. If a process instance has been completed already, this method will return
null
.I noticed also that when kbase don't have process definition which instance try to load it also return null (in 5.4).
ts
-
4. Re: calling the setVariable on reloaded ProcessInstance leads to NullPointerException
obon Mar 4, 2013 7:30 AM (in response to amadets)as I pointed out, the problem is not because the returned active process instance null, but because it is not completely initialized.
The exception happens in the following method of the class org.jbpm.process.instance.impl.ProcessInstanceImpl:
public Process getProcess() { if (this.process == null) { this.process = kruntime.getKnowledgeBase().getProcess(processId); } return this.process; }
The kruntime is null.
I hope, now the problem is clearly and completely described.
-
5. Re: calling the setVariable on reloaded ProcessInstance leads to NullPointerException
obon Mar 4, 2013 8:37 AM (in response to obon)got it.
wrap the whole thing in a transaction, also described here: