0 Replies Latest reply on Jul 13, 2010 1:22 PM by imjorge

    Error deleting SwimlaneImpl when a task has swimlanes and events with timer

    imjorge

      Hello,

       

      jBPM 4.3 running on a Windows XP SP2 box (same behavior for a Windows 7).

       

      We are having some difficulties configuring events together with timers and swimlanes. There seems to be a problem when jBPM tries to delete a swimlane when completeTask is called.

       

      We configured a console application (attached to post) that reproduces this error. After running the application the following error is shown:

       

      org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.task.SwimlaneImpl#15]
          [...]
          at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:88)
          at com.test.Main.main(Main.java:83)
      Caused by: java.sql.SQLException: Integrity constraint violation FK_TASK_SWIML table: JBPM4_TASK in statement [delete from JBPM4_SWIMLANE where DBID_=? and DBVERSION_=?]
          at org.hsqldb.jdbc.Util.throwError(Unknown Source)
          at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
          at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2551)
          ... 54 more
      Exception in thread "main" org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.task.SwimlaneImpl#15]
          [...]
          at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:88)
          at com.test.Main.main(Main.java:83)
      Caused by: java.sql.SQLException: Integrity constraint violation FK_TASK_SWIML table: JBPM4_TASK in statement [delete from JBPM4_SWIMLANE where DBID_=? and DBVERSION_=?]
          at org.hsqldb.jdbc.Util.throwError(Unknown Source)
          at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
          at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2551)
          ... 54 more

       

       

      The sequence of SQL statements (as logged by p6spy) are:

       

      update JBPM4_TASK set DBVERSION_=3, NAME_='task2', DESCR_='', STATE_='open', SUSPHISTSTATE_='', ASSIGNEE_='b', FORM_='', PRIORITY_=0, CREATE_='2010-07-13 16:36:53.007', DUEDATE_='', PROGRESS_='', SIGNALLING_='false', EXECUTION_ID_='test3.7.task2', ACTIVITY_NAME_='task2', HASVARS_='false', SUPERTASK_='', EXECUTION_=12, PROCINST_=7, SWIMLANE_=15, TASKDEFNAME_='task2' where DBID_=14 and DBVERSION_=2
      update JBPM4_EXECUTION set DBVERSION_=3, ACTIVITYNAME_='end1', PROCDEFID_='test3-1', HASVARS_='true', NAME_='', KEY_='', ID_='test3.7', STATE_='ended', SUSPHISTSTATE_='', PRIORITY_=0, HISACTINST_=11, PARENT_='', INSTANCE_=7, SUPEREXEC_='', SUBPROCINST_='' where DBID_=7 and DBVERSION_=2
      update JBPM4_HIST_ACTINST set DBVERSION_=1, HPROCI_=7, TYPE_='task', EXECUTION_='test3.7.task2', ACTIVITY_NAME_='task2', START_='2010-07-13 16:36:53.007', END_='2010-07-13 16:39:56.991', DURATION_=183984, TRANSITION_='jbpm_no_task_outcome_specified_jbpm', NEXTIDX_=1, HTASK_=14 where DBID_=20 and DBVERSION_=0
      update JBPM4_HIST_TASK set DBVERSION_=2, EXECUTION_='test3.7.task2', OUTCOME_='jbpm_no_task_outcome_specified_jbpm', ASSIGNEE_='b', PRIORITY_=0, STATE_='completed', CREATE_='2010-07-13 16:36:53.007', END_='2010-07-13 16:39:56.991', DURATION_=183984, NEXTIDX_=1 where DBID_=14 and DBVERSION_=1
      update JBPM4_HIST_PROCINST set DBVERSION_=1, ID_='test3.7', PROCDEFID_='test3-1', KEY_='', START_='2010-07-13 16:36:52.337', END_='2010-07-13 16:39:57.101', DURATION_=184764, STATE_='ended', ENDACTIVITY_='end1', NEXTIDX_=1 where DBID_=7 and DBVERSION_=0
      update JBPM4_SWIMLANE set EXECUTION_=null, NAME_=null where EXECUTION_=12
      update JBPM4_PARTICIPATION set SWIMLANE_=null where SWIMLANE_=15
      update JBPM4_EXECUTION set PARENT_=null, PARENT_IDX_=null where PARENT_=7
      delete from JBPM4_PARTICIPATION where DBID_=17 and DBVERSION_=0
      delete from JBPM4_PARTICIPATION where DBID_=16 and DBVERSION_=0
      delete from JBPM4_SWIMLANE where DBID_=15 and DBVERSION_=1

       

      The problem appears when the last line:

      delete from JBPM4_SWIMLANE where DBID_=15 and DBVERSION_=1

       

      is executed. This is caused because a record in table JBPM4_TASK still exists that points to the JBPM4_SWIMLANE record that is being deleted. In this case I would guess that the first SQL statement:

      update JBPM4_TASK set DBVERSION_=3, NAME_='task2', DESCR_='', STATE_='open', SUSPHISTSTATE_='', ASSIGNEE_='b', FORM_='', PRIORITY_=0, CREATE_='2010-07-13 16:36:53.007', DUEDATE_='', PROGRESS_='', SIGNALLING_='false', EXECUTION_ID_='test3.7.task2', ACTIVITY_NAME_='task2', HASVARS_='false', SUPERTASK_='', EXECUTION_=12, PROCINST_=7, SWIMLANE_=15, TASKDEFNAME_='task2' where DBID_=14 and DBVERSION_=2

       

      should have set swimlane_ to null so that the last delete would suceed. These SQL statements are automatically generated by Hibernate. Is there something missing from the hbm files that come with the jBPM distribution?

       

      This only happens if the task has an <on event> with a timer configured and a swimlane. If the <timer> is commented or if the swimlane is replaced by the equivalent candidate-users the application does not fail with this error.