1 Reply Latest reply on Nov 16, 2010 6:48 PM by Alejandro Guizar

    Task Instance Not Ending

    shiva shankar Newbie

      Hi,

       

      I have following process definition.

       

      <?xml version="1.0" encoding="UTF-8"?>

      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
         <start-state name="start">
            <transition name="Start" to="Step1"></transition>
         </start-state>
         <end-state name="end"></end-state>
         <task-node name="Step1">
            <task name="Step1">
               <assignment class="com.sample.SimpleAssignmentHandler"></assignment>
            </task>
            <transition name="Step2" to="Step2"></transition>
         </task-node>
         <task-node name="Step2">
            <task name="Step2"></task>
            <transition name="End" to="end"></transition>
         </task-node>
      </process-definition>

       

      i had deployed the process definition using below code.

       

      JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
      String businessKey="";
      FileInputStream fis=new FileInputStream("D:/java_pro/simple.zip");
      ZipInputStream zis=new ZipInputStream(new BufferedInputStream(fis));
      ProcessDefinition processDefinition=ProcessDefinition.parseParZipInputStream(zis);
      GraphSession gs=jbpmContext.getGraphSession();
      gs.deployProcessDefinition(processDefinition);
      for(int i=0;i<=5;i++){
                      ProcessInstance processInstance=jbpmContext.newProcessInstance(processDefinition.getName());
                      businessKey="KEY15102010"+i;
                      processInstance.setKey(businessKey);
                      //processInstance=jbpmContext.getProcessInstance(processInstance.getId());
                      Token token=processInstance.getRootToken();
                      Transition transition=(Transition)token.getAvailableTransitions().iterator().next();
                      token.signal(transition);
                      //jbpmContext.save(processInstance);
                  }
                
      jbpmContext.close();

       

      and i have writen the following code to end a process instance

       

      JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
      TaskInstance taskInstance=jbpmContext.getTaskInstance(2900);
      ProcessInstance processInstance=taskInstance.getProcessInstance();
      taskInstance.start();
      Token token=taskInstance.getToken();           
      Transition transition=(Transition)token.getAvailableTransitions().iterator().next();
      token.signal(transition);
      taskInstance.end(transition);
      jbpmContext.close();

       

      but i am getting the following error if i am trying to execute above program.

       

      22:58:40,656 [main] DEBUG GraphElement : event 'task-start' on 'Task(Step1)' for 'Token(/)'
      22:58:41,562 [main] DEBUG GraphElement : event 'before-signal' on 'TaskNode(Step1)' for 'Token(/)'
      22:58:41,609 [main] DEBUG GraphElement : event 'node-leave' on 'TaskNode(Step1)' for 'Token(/)'
      22:58:41,609 [main] DEBUG GraphElement : event 'transition' on 'Transition(Step2)' for 'Token(/)'
      22:58:41,734 [main] DEBUG GraphElement : event 'node-enter' on 'TaskNode(Step2)' for 'Token(/)'
      22:58:41,796 [main] WARN  StatefulPersistenceContext : Narrowing proxy to class org.jbpm.graph.node.TaskNode - this operation breaks ==
      org.jbpm.persistence.JbpmPersistenceException: couldn't assign id to TaskInstance[Step2]
      22:58:42,828 [main] WARN  JDBCExceptionReporter : SQL Error: 1400, SQLState: 23000
      22:58:42,828 [main] ERROR JDBCExceptionReporter : ORA-01400: cannot insert NULL into ("WORKFLOW"."JBPM_TASKINSTANCE"."ID_")

       

          at org.jbpm.persistence.db.DbPersistenceService.assignId(DbPersistenceService.java:333)
          at org.jbpm.svc.Services.assignId(Services.java:257)
          at org.jbpm.taskmgmt.exe.TaskMgmtInstance.createTaskInstance(TaskMgmtInstance.java:116)
          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.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
          at org.jbpm.taskmgmt.exe.TaskMgmtInstance$$EnhancerByCGLIB$$2c2b22b2.createTaskInstance(<generated>)
          at org.jbpm.graph.node.TaskNode.execute(TaskNode.java:168)
          at org.jbpm.graph.def.Node.enter(Node.java:319)
          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.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
          at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$d655f97c.enter(<generated>)
          at org.jbpm.graph.def.Transition.take(Transition.java:151)
          at org.jbpm.graph.def.Node.leave(Node.java:394)
          at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:209)
          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.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
          at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$109befc6.leave(<generated>)
          at org.jbpm.graph.exe.Token.signal(Token.java:195)
          at org.jbpm.graph.exe.Token.signal(Token.java:166)
          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.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
          at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$82e4a010.signal(<generated>)
          at com.leavemanagement.TestFlow.main(TestFlow.java:28)
      Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [org.jbpm.taskmgmt.exe.TaskInstance]
          at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
          at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
          at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
          at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
          at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
          at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
          at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
          at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
          at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
          at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
          at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
          at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
          at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
          at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
          at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
          at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
          at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
          at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
          at org.jbpm.persistence.db.DbPersistenceService.assignId(DbPersistenceService.java:330)
          ... 34 more
      Caused by: java.sql.SQLException: ORA-01400: cannot insert NULL into ("WORKFLOW"."JBPM_TASKINSTANCE"."ID_")

       

          at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
          at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
          at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
          at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
          at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
          at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
          at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
          at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
          at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
          at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73)
          at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
          ... 50 more

       

      Note: i am able to end a task instance if there is only one task node.

       

      Please suggest a solution.thanks.

        • 1. Re: Task Instance Not Ending
          Alejandro Guizar Master

          Ending a task instance generally results in the related token being signaled, you should not be signaling the token separately.

          In addition, calling TaskInstance.end() or Token.signal() without parameters results in the default transition being taken, you should not be calling token.getAvailableTransitions().iterator().next() to retrieve the transition.

          Hope this helps.