Thanks for the immediate reply, I tried the following:
Code:
JbpmTemplate template = (JbpmTemplate) ctx.getBean("jbpmTemplate");
ProcessDefinition def = template.getJbpmConfiguration().createJbpmContext().getGraphSession().findLatestProcessDefinition("process1");
template.setProcessDefinition(def);
template.execute(new JbpmCallback() {
public Object doInJbpm(JbpmContext context) {
ProcessInstance inst = context.newProcessInstanceForUpdate("process1");
inst.signal();
context.save(inst);
// dummy return
return null;
}
})
which gives me the following exception:
Code:
Exception in thread "main" org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:526)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1205)
at $Proxy4.save(Unknown Source)
at org.jbpm.svc.save.HibernateSaveOperation.save(HibernateSaveOperation.java:38)
at org.jbpm.svc.Services.save(Services.java:156)
at org.jbpm.JbpmContext.save(JbpmContext.java:388)
at org.jbpm.JbpmContext.autoSave(JbpmContext.java:586)
at org.jbpm.JbpmContext.close(JbpmContext.java:137)
at org.springmodules.workflow.jbpm31.JbpmTemplate.releaseContext(JbpmTemplate.java:111)
at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:100)
here is my spring config
Code:
<bean id="jbpmConfig" class="org.blah.blah.jbpm.CustomLocalJbpmConfigurationFactoryBean">
<!-- pass in existing sessionFactory -->
<property name="sessionFactory" ref="jbpmSessionFactory"/>
<property name="configuration" value="org/blah/blah/jbpm/jbpm.cfg.xml"/>
</bean>
<bean id="jbpmTemplate" class="org.springmodules.workflow.jbpm31.JbpmTemplate">
<constructor-arg index="0" ref="jbpmConfig"/>
</bean>
however, this works like a charm for me:
Code:
JbpmConfiguration config = (JbpmConfiguration) ctx.getBean("jbpmConfig");
JbpmContext context = config.createJbpmContext();
ProcessDefinition def = context.getGraphSession().findLatestProcessDefinition("process1");
ProcessInstance in = def.createProcessInstance();
ContextInstance cn = in.getContextInstance();
List l = new ArrayList();
l.add("batman");
l.add("joker");
cn.setVariable("list", l);
in.signal();
context.save(in);
context.close();
I am bypassing the jbpm template altogether, I can use the above solution for now, although would love to get the jbpm template working.
Thanks,
meeru