9 Replies Latest reply on Feb 18, 2009 6:00 AM by tom.baeyens

    deletion problem

    tom.baeyens

       

      "jeff" wrote:
      hello, tom... i am looking forward to receive your reply...

      i came up with some problems again...
      i would like to run a persistent execution mode test...
      i worked quite well when deploy, start a new process instance with a process definition,
      but when i resume a persisted process instance, something i don't know what to do happened..

      my source code & jvm stack:

      public class PersistentExecutionModeTest extends EnvironmentFactoryTestCase {

      SessionFactory sessionFactory;
      Session session;
      Transaction transaction;

      public void testDeploy() { // seems ok
      // /*
      JbpmConfiguration environmentFactory = (JbpmConfiguration)getEnvironmentFactory();
      ProcessService processService = environmentFactory.get(ProcessService.class);

      ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
      .startProcess("test")

      .startActivity("start", WaitState.class)
      .initial()
      .flow("end","end")
      .endActivity()

      .startActivity("end", AutomaticActivity.class)
      .endActivity()

      .endProcess();

      Deployment deployment = new DeploymentImpl();
      deployment.addObject("testProcesssss", processDefinition);

      ((ProcessServiceImpl) processService).deploy(deployment);
      // */
      }

      public void testStartProcessInstance() { // seems ok, 2

      JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
      ExecutionService executionService = environmentFactory.get(ExecutionService.class);
      Execution execution = executionService.startProcessInstanceById("test:1", "request17");
      }

      public void testResumeProcessInstance(){ // something wrong...

      JbpmConfiguration environmentFactory = (JbpmConfiguration)getEnvironmentFactory();
      ExecutionService executionService = environmentFactory.get(ExecutionService.class);
      Execution execution = executionService.signalExecutionById("test/request17", "end"); // exception occured here

      }

      }

      here is problems:
      Hibernate:
      /* delete org.jbpm.pvm.internal.model.ExecutionImpl */ delete
      from
      JBPM_EXECUTION
      where
      DBID_=?
      and DBVERSION_=?
      10:36:37,578 WRN | [JDBCExceptionReporter] SQL Error: 1451, SQLState: 23000
      10:36:37,578 SEV | [JDBCExceptionReporter] Cannot delete or update a parent row: a foreign key constraint fails (`jbpm_pvm/jbpm_execution`, CONSTRAINT `FK_EXEC_INSTANCE` FOREIGN KEY (`INSTANCE_`) REFERENCES `jbpm_execution` (`DBID_`))
      ### EXCEPTION ###########################################
      10:36:37,578 SEV | [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#4]
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2546)
      at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2702)
      at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:77)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:172)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:54)
      at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:106)
      at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:65)
      at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
      at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:52)
      at org.jbpm.pvm.internal.model.ProcessInstanceEndedSynchronization.afterCompletion(ProcessInstanceEndedSynchronization.java:52)
      at org.jbpm.pvm.internal.tx.StandardSynchronization.afterCompletion(StandardSynchronization.java:41)
      at org.jbpm.pvm.internal.tx.StandardTransaction.afterCompletion(StandardTransaction.java:213)
      at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:153)
      at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:65)
      at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
      at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
      at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:52)
      at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:97)
      at org.jbpm.pvm.executionmode.persistence.PersistentExecutionModeTest.testResumeProcessInstance(PersistentExecutionModeTest.java:81)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at junit.framework.TestCase.runTest(TestCase.java:164)
      at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:81)
      at junit.framework.TestCase.runBare(TestCase.java:130)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:230)
      at junit.framework.TestSuite.run(TestSuite.java:225)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      BY THE WAY,
      at this line: Execution execution = executionService.signalExecutionById("test/request17", "end");
      as referenced in the previous version manual, here should be call the method with the parameters ("test:1/request17", "end")?
      but i got exception as nothing found, and i trace the source code to DefaultIdGenerator#createId
      ....
      if (parent!=null) {
      base = parent.getId();
      } else if (processDefinition.getKey()!=null){ // processDefinition.getKey() = "test"
      base = processDefinition.getKey();
      } else {
      base = processDefinition.getId();
      }
      ....
      is there anything wrong with my process definition? or because of my wrongful use of the API?


      regards, jeff


        • 1. Re: deletion problem
          tom.baeyens

          is this with the latest code ?

          i added this test to the pvm test suite and it ran fine. It's called org.jbpm.pvm.internal.execution.PvmProcessExecutionTest.

          can you see if you can reproduce your problem based on that test ?

          • 2. Re: deletion problem
            galanfish

            oh... it's my mistake...
            i wrongfully set hibernate.dialect=org.hibernate.dialect.MySQLDialect
            and i fixed it as hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect, then the testcase runned well...

            by the way, is that a execution would be set state to 'ended' when it is finished? and the pvm will delete the record from the table 'jbpm_execution'? can i cancel this? i mean when the execution finished, can i keep the record in database just update the state to 'ended'?

            • 3. Re: deletion problem
              tom.baeyens

              you'll still find that execution in the history. see HistoryService.

              runtime execution tables need to be kept clean to keep the runtime system healthy.

              • 4. Re: deletion problem
                galanfish

                is that the history is stored in the table 'jbpm_hist_actinst' and 'jbpm_hist_procinst'?
                but they keep empty, where should i configure? or code?
                thx

                • 5. Re: deletion problem
                  tom.baeyens

                  thats a configuration issue.

                  configure history-service and history-session as in jbpm4/trunk/modules/test-db/src/main/test/resources/jbpm.cfg.xml

                  • 6. Re: deletion problem
                    galanfish

                    thx, and what is the table 'jbpm_hist_actinst' used for? i found nothing in it..
                    is that the table 'jbpm_execution' should never find a record with state=ended?

                    • 7. Re: deletion problem
                      galanfish

                      is that i have to call historyXX in my own activitybehaviour implementation's execute(Execution) method?

                      • 8. Re: deletion problem
                        tom.baeyens

                         

                        "galanfish" wrote:
                        thx, and what is the table 'jbpm_hist_actinst' used for? i found nothing in it..
                        is that the table 'jbpm_execution' should never find a record with state=ended?


                        activities can store activit instance records in it. @see the ActivityExecution.historyXxxx methods

                        • 9. Re: deletion problem
                          tom.baeyens

                           

                          "galanfish" wrote:
                          is that i have to call historyXX in my own activitybehaviour implementation's execute(Execution) method?


                          ah yes, you found it already.