4 Replies Latest reply on Jan 14, 2009 9:23 AM by Ronald van Kuijk

    define process definition with jbpm's api

    nesta fdb Newbie

      jbpm3.1.2

      I define process as follows:

      ProcessDefinition definition = new ProcessDefinition();
      definition.setName("hello world");
      
      Transition open = new Transition("open");
      open.setProcessDefinition(definition);
      
      StartState newS = new StartState("new");
      newS.addLeavingTransition(open);
      
      State openS = new State("open");
      openS.addArrivingTransition(open);
      
      open.setFrom(newS);
      open.setTo(openS);
      
      EndState end = new EndState("close");
      
      Transition close = new Transition("close");
      close.setFrom(openS);
      close.setTo(end);
      close.setProcessDefinition(definition);
      openS.addLeavingTransition(close);
      end.addArrivingTransition(close);
      
      definition.setStartState(newS);
      definition.addNode(openS);
      definition.addNode(end);
      

      I can deploy it successfully, but when I store variables in new process instance, it fails.
       GraphSession gs = jbpmContext.getGraphSession();
       ProcessDefinition pd = gs.findLatestProcessDefinition("hello world");
       ProcessInstance pi = new ProcessInstance(pd);
       ContextInstance ci = pi.getContextInstance();
       ci.setVariable("name", "jnesta");
       jbpmContext.save(pi);
       jbpmContext.close();
      


      But it runs successfully when parse process string like jbpm's "hello world" example.

      So I think that I miss something in process definition.

      Thanks in advance.

      error message:
      Hibernate: select processdef0_.ID_ as ID1_1_, processdef0_.NAME_ as NAME2_1_, processdef0_.VERSION_ as VERSION3_1_, processdef0_.ISTERMINATIONIMPLICIT_ as ISTERMIN4_1_, processdef0_.STARTSTATE_ as STARTSTATE5_1_ from JBPM_PROCESSDEFINITION processdef0_ where processdef0_.NAME_=? order by processdef0_.VERSION_ desc limit ?
      Hibernate: insert into JBPM_TOKEN (VERSION_, NAME_, START_, END_, NODEENTER_, NEXTLOGINDEX_, ISABLETOREACTIVATEPARENT_, ISTERMINATIONIMPLICIT_, ISSUSPENDED_, NODE_, PROCESSINSTANCE_, PARENT_, SUBPROCESSINSTANCE_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      Hibernate: insert into JBPM_PROCESSINSTANCE (VERSION_, START_, END_, ISSUSPENDED_, PROCESSDEFINITION_, ROOTTOKEN_, SUPERPROCESSTOKEN_) values (?, ?, ?, ?, ?, ?, ?)
      Hibernate: select definition0_.PROCESSDEFINITION_ as PROCESSD4_1_, definition0_.ID_ as ID1_1_, definition0_.NAME_ as NAME3_1_, definition0_.ID_ as ID1_13_0_, definition0_.NAME_ as NAME3_13_0_, definition0_.PROCESSDEFINITION_ as PROCESSD4_13_0_, definition0_.STARTTASK_ as STARTTASK5_13_0_, definition0_.CLASS_ as CLASS2_13_0_ from JBPM_MODULEDEFINITION definition0_ where definition0_.PROCESSDEFINITION_=?
      Hibernate: select events0_.PROCESSDEFINITION_ as PROCESSD5_1_, events0_.ID_ as ID1_1_, events0_.EVENTTYPE_ as EVENTTYPE2_1_, events0_.ID_ as ID1_4_0_, events0_.EVENTTYPE_ as EVENTTYPE2_4_0_, events0_.TYPE_ as TYPE3_4_0_, events0_.GRAPHELEMENT_ as GRAPHELE4_4_0_ from JBPM_EVENT events0_ where events0_.PROCESSDEFINITION_=?
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, CLASS_) values (?, ?, ?, ?, 'I')
      Hibernate: insert into JBPM_VARIABLEINSTANCE (NAME_, CONVERTER_, TOKEN_, TOKENVARIABLEMAP_, PROCESSINSTANCE_, STRINGVALUE_, CLASS_) values (?, ?, ?, ?, ?, ?, 'S')
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, VARIABLEINSTANCE_, CLASS_) values (?, ?, ?, ?, ?, 'R')
      Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, VARIABLEINSTANCE_, OLDSTRINGVALUE_, NEWSTRINGVALUE_, CLASS_) values (?, ?, ?, ?, ?, ?, ?, 'U')
      org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close (DbPersistenceService.java:172)
      at org.jbpm.svc.Services.close(Services.java:211)
      at org.jbpm.JbpmContext.close(JbpmContext.java:139)
      at net.nesta.jbpm.impl.WorkflowServiceImpl.startWorkf low(WorkflowServiceImpl.java:72)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:281)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:187)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :154)
      at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:107)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :176)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:210)
      at $Proxy6.startWorkflow(Unknown Source)
      at test.DoTest.testStart(DoTest.java:21)
      at test.DoTest.main(DoTest.java:15)
      Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.context.exe.TokenVariableMap
      at org.hibernate.engine.ForeignKeys.getEntityIdentifi erIfNotUnsaved(ForeignKeys.java:216)
      at org.hibernate.type.EntityType.getIdentifier(Entity Type.java:108)
      at org.hibernate.type.ManyToOneType.isDirty(ManyToOne Type.java:221)
      at org.hibernate.type.TypeFactory.findDirty(TypeFacto ry.java:476)
      at org.hibernate.persister.entity.AbstractEntityPersi ster.findDirty(AbstractEntityPersister.java:2803)
      at org.hibernate.event.def.DefaultFlushEntityEventLis tener.dirtyCheck(DefaultFlushEntityEventListener.j ava:467)
      at org.hibernate.event.def.DefaultFlushEntityEventLis tener.isUpdateNecessary(DefaultFlushEntityEventLis tener.java:190)
      at org.hibernate.event.def.DefaultFlushEntityEventLis tener.onFlushEntity(DefaultFlushEntityEventListene r.java:113)
      at org.hibernate.event.def.AbstractFlushingEventListe ner.flushEntities(AbstractFlushingEventListener.ja va:195)
      at org.hibernate.event.def.AbstractFlushingEventListe ner.flushEverythingToExecutions(AbstractFlushingEv entListener.java:76)
      at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:26)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:980)
      at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close (DbPersistenceService.java:162)


      error message: