1 Reply Latest reply on Aug 5, 2006 9:54 AM by Ronald van Kuijk

    signalling with newly created token instance

    mahesh patel Newbie

      hi i created an instance of token and trying to signal the process with the newly created token. here im not using the root token for signalling. so im trying to save the data in the tables and im getting the token id of the root token as 500 and the token which i created has the token id 0. and its throwing the error hibernate transient object exception. can any one just help me out


      here is the code


      package com.westpac.nzlo.tempjbpm;

      import java.io.BufferedReader;
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.IOException;
      import java.io.InputStreamReader;

      import org.jbpm.JbpmConfiguration;
      import org.jbpm.JbpmContext;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.exe.Token;

      public class CreateDuplicateToken {

      /**
      * @param args
      */
      public static void main(String[] args) {
      // TODO Auto-generated method stub

      JbpmConfiguration jbpmConfiguration = null;
      JbpmContext jbpmContext = null;

      try {
      jbpmConfiguration = JbpmConfiguration.parseInputStream(new FileInputStream("src/config.files/jbpm.cfg.xml"));
      } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      jbpmContext = jbpmConfiguration.createJbpmContext();

      System.out.println("Create Duplicate Token:");
      System.out.print("Enter the ProcessInstance ID: ");

      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      long processInstanceID = 0 ;
      try {
      processInstanceID = Long.parseLong(br.readLine());
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }


      ProcessInstance processInstance = jbpmContext.loadProcessInstanceForUpdate(processInstanceID);

      Token rootToken = processInstance.getRootToken();

      Token duplicateToken = new Token();

      duplicateToken.setNode(rootToken.getNode());


      System.out.println("Root TokenID: "+rootToken.getId());
      System.out.println("Duplicate TokenID: "+duplicateToken.getId());
      System.out.println("ProcessInstance of Duplicate: "+duplicateToken.getProcessInstance().getId());
      System.out.println("Parent of Duplicate: "+duplicateToken.getParent().getId());


      jbpmContext.save(duplicateToken);
      duplicateToken.signal();
      jbpmContext.save(duplicateToken);

      jbpmContext.close();

      }

      }




      here is the exception



      org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
      at org.jbpm.svc.Services.close(Services.java:211)
      at org.jbpm.JbpmContext.close(JbpmContext.java:141)
      at com.westpac.nzlo.tempjbpm.CreateDuplicateToken.main(CreateDuplicateToken.java:66)
      Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.exe.Token
      at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
      at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
      at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
      at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
      ... 3 more
      18:06:33,500 [main] ERROR Services : problem closing service 'persistence'
      org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
      at org.jbpm.svc.Services.close(Services.java:211)
      at org.jbpm.JbpmContext.close(JbpmContext.java:141)
      at com.westpac.nzlo.tempjbpm.CreateDuplicateToken.main(CreateDuplicateToken.java:66)
      Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.exe.Token
      at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
      at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
      at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
      at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
      ... 3 more
      org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session}
      at org.jbpm.svc.Services.close(Services.java:223)
      at org.jbpm.JbpmContext.close(JbpmContext.java:141)
      at com.westpac.nzlo.tempjbpm.CreateDuplicateToken.main(CreateDuplicateToken.java:66)
      Caused by: org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
      at org.jbpm.svc.Services.close(Services.java:211)
      ... 2 more
      Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.graph.exe.Token
      at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
      at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
      at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
      at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
      ... 3 more


      thnx