-
1. Re: context variables not being persisted
kukeltje Mar 10, 2008 12:40 PM (in response to mabogunje)also close the context
-
2. Re: context variables not being persisted
mabogunje Mar 10, 2008 12:50 PM (in response to mabogunje)Actually I am closing the context, here is the full code :
JbpmContext jbpmContext = s_jbpmConfiguration.createJbpmContext();
try
{
ProcessDefinition definition = jbpmContext.getGraphSession().getProcessDefinition(Long.parseLong(instanceTO.getTemplateId()));
ProcessInstance instance = new ProcessInstance(definition);
ContextInstance contextInstance = (ContextInstance)instance.getInstance(ContextInstance.class);
contextInstance.setVariable("name","name");
contextInstance.createVariable("test","test");
jbpmContext.save(instance);
}
catch (Exception e)
{
throw new WorkflowEngineException(e.getMessage(), e);
}
finally
{
jbpmContext.close();
}
Also when I look in the ProcessInstance object during runtime, there are instances and transientInstances, however instances remains null, while transient instance contains my ContextInstance and LoggingInstance. As I add variables, they are being added to my transient instance. Is that correct ? That seems like the reason they are not being persisted but I dont know why its happening.
Thanks for all your help -
3. Re: context variables not being persisted
mabogunje Mar 12, 2008 10:05 AM (in response to mabogunje)Well it seems like when I create the process definition by parsing the xml definition everything works fine.
What I was trying to do was programmatically create my process definition. By creating a new process definition object and adding nodes and transitions to it.
Note that in both scenarios the resulting instances are identical except for the fact that in one case the instance variables a transient and thus not saved.
Any thoughts on why this might be happening ? There arent any examples on creating a ProcessDefinition programmatically.