7 Replies Latest reply on Jun 18, 2009 9:10 PM by joshsiaw

    jBPM 4 CR1 AsyncActivity Unit Test fails due to FK constrain

      Hi, I just installed jBPM4 CR1 yesterday and have been trying out the examples and testing the api. I tried to run testAsyncActivity on JUnit and it failed with this error. Btw, I'm using MySQL 5 for the JBPM db.

      19:11:49,159 FIN | [ProcessDefinitionImpl] creating new execution for process 'AsyncActivity'
      19:11:49,159 FIN | [DefaultIdGenerator] generated execution id AsyncActivity.7
      19:11:49,159 FIN | [ExecuteActivity] executing activity(18093512)
      19:11:49,174 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
      19:11:49,221 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[8]...
      19:11:49,237 FIN | [ExecuteActivity] executing activity(generate pdf)
      19:11:49,237 FIN | [JobExecutorMessageSession] sending message ExecuteActivityMessage
      19:11:49,237 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[8]
      19:11:49,284 FIN | [ExecuteJobCmd] executing job ExecuteActivityMessage[9]...
      19:11:49,299 FIN | [ExecuteActivity] executing activity(calculate primes)
      19:11:49,299 FIN | [ExecuteActivity] executing activity(end)
      19:11:49,299 FIN | [Execution] process-instance ends with state ended
      19:11:49,315 FIN | [DbSessionImpl] deleting process instance AsyncActivity.7
      19:11:49,315 FIN | [ExecuteJobCmd] executed job ExecuteActivityMessage[9]
      19:11:49,315 WRN | [JDBCExceptionReporter] SQL Error: 1451, SQLState: 23000
      19:11:49,315 SEV | [JDBCExceptionReporter] Cannot delete or update a parent row: a foreign key constraint fails (`jbpmdb/jbpm4_execution`, CONSTRAINT `FK_EXEC_INSTANCE` FOREIGN KEY (`INSTANCE_`) REFERENCES `jbpm4_execution` (`DBID_`))
      ### EXCEPTION ###########################################
      19:11:49,315 SEV | [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.jpdl.internal.model.JpdlExecution#7]
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
       at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2569)
       at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2725)
       at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97)
      


      Basically the test is failing to delete the process instance after the jobs are done and the process reaches the end state. Does anyone have a solution for this problem? Did I setup my db connection incorrectly?

      Any help would be appreciated. Thanks.

        • 1. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const
          kukeltje

          If you would search the forum, you'd see that (unfortunately?) many people suffer identical issues and a jira issue is already posted which could be (is?) related to this. Can you check if it seam related...

          • 2. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const

            Thanks for your quick reply. I did search the forums and jira (sorry I didn't mention that) but wasn't sure if it was due to the same problem so I thought I'd post this specify the unit test which failed.

            As far as I can tell since trying other tests(EndProcessInstanceTest, EndStateTest, etc), anything related to deleting a process instance hits this FK constraint error. I don't think its seam related since I'm not using it (and I don't really how to use it). I'm just running tests and using java classes to call the api.

            Anything else I can do to help identify the problem? Deleting process definitions and instances work fine in the GWT console so I'm puzzled as to why this doesn't work. I'd assume they use the same api.

            • 3. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const
              kukeltje

              hahaha I meant to say if it seams related..... slip of the pen.
              Could you post your db config files (hibernate, -ds.xml etc..)

              • 4. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const

                Here you go:

                jbpm.cfg.xml file:

                <?xml version="1.0" encoding="UTF-8"?>
                
                <jbpm-configuration>
                
                 <import resource="jbpm.default.cfg.xml" />
                 <import resource="jbpm.tx.hibernate.cfg.xml" />
                 <import resource="jbpm.jpdl.cfg.xml" />
                 <import resource="jbpm.identity.cfg.xml" />
                
                 <!-- Job executor is excluded for running the example test cases. -->
                 <!-- To enable timers and messages in production use, this should be included. -->
                 <!--
                 <import resource="jbpm.jobexecutor.cfg.xml" />
                 -->
                
                 <import resource="jbpm.mail.templates.examples.xml" />
                
                </jbpm-configuration>
                


                jbpm.hibernate.cfg.xml file:
                <?xml version="1.0" encoding="utf-8"?>
                
                <!DOCTYPE hibernate-configuration PUBLIC
                 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
                
                <hibernate-configuration>
                 <session-factory>
                
                 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
                 <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
                 <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpmdb</property>
                 <property name="hibernate.connection.username">root</property>
                 <property name="hibernate.connection.password">p4ssw0rd</property>
                 <property name="hibernate.hbm2ddl.auto">update</property>
                 <property name="hibernate.format_sql">true</property>
                
                 <mapping resource="jbpm.repository.hbm.xml" />
                 <mapping resource="jbpm.execution.hbm.xml" />
                 <mapping resource="jbpm.history.hbm.xml" />
                 <mapping resource="jbpm.task.hbm.xml" />
                 <mapping resource="jbpm.jpdl.hbm.xml" />
                 <mapping resource="jbpm.identity.hbm.xml" />
                
                 </session-factory>
                </hibernate-configuration>
                


                logging.properties file:
                handlers= java.util.logging.ConsoleHandler
                redirect.commons.logging = enabled
                
                java.util.logging.ConsoleHandler.level = FINE
                java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
                
                org.jbpm.level=FINE
                # org.jbpm.pvm.internal.tx.level=FINE
                # org.jbpm.pvm.internal.wire.level=FINE
                # org.jbpm.pvm.internal.util.level=FINE
                
                org.hibernate.level=INFO
                org.hibernate.cfg.SettingsFactory.level=SEVERE
                org.hibernate.cfg.HbmBinder.level=SEVERE
                # org.hibernate.SQL.level=FINEST
                # org.hibernate.type.level=FINEST
                # org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
                # org.hibernate.transaction.level=FINEST
                


                I don't have a -ds.xml file though. Is that needed? I ran the build.xml using ant with the datasource settings modified in the build file. This is what I modified:

                <!-- DEFAULT PROPERTY VALUES -->
                 <property name="database" value="mysql" />
                 <property name="jbpm.parent.dir" value="../.." />
                 <property name="jbpm.version" value="4.0.CR1" />
                 <property name="jboss.version" value="5.0.0.GA" />
                 <property name="jbpm.home" value="${jbpm.parent.dir}/jbpm-${jbpm.version}" />
                


                • 5. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const
                  kukeltje

                  I've tested it and the way jBPM is providing all mysql setup data it works like a charm.

                  I noticed one difference though. I use the org.hibernate.dialect.MySQLInnoDBDialect instead of what you use. Since I'm no DB expert I do not know the difference not do I intent to find out, but you might give it a try.

                  • 6. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const
                    kukeltje

                    Yep, confirmed. If I change my dialect to yours, I get the same error.

                    • 7. Re: jBPM 4 CR1 AsyncActivity Unit Test fails due to FK const

                      That did it! Thanks so much! Now it makes sense. If I remember correctly InnoDb storage type allows you to carry out executions in 'safe' transactions and enforces foreign key constraints, etc to maintain db integrity.

                      Quite possibly the other dialect I was using did not enforce such rules so it was rejected. My db is definitely using InnoDb storage. This is probably true for most people using MySQL since it's the default type when installing MySQL server.

                      Anyways, that was just additional info. Thanks again!