[JBoss jBPM] - jBPM 4 CR1 AsyncActivity Unit Test fails due to FK constrain
by joshsiaw
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.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237865#4237865
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4237865
17 years, 1 month
[JBoss jBPM] - Re: Signal process instance asynchronous
by hhhuber
there are reasons why i don't want to make the first node 'async'. so i kept looking for a way to signal a process asynchronously. this is what i implemented:
a AsyncProcessSignalJob that can be saved as a jbpm-job. then the job executor finds and executes the job as any other job.
| public class AsyncProcessSignalJob extends Job {
|
| /** The Constant serialVersionUID. */
| private static final long serialVersionUID = -8358943330005955423L;
|
| public AsyncProcessSignalJob() {
| }
|
| public AsyncProcessSignalJob(ProcessInstance processInstance) {
| this.setDueDate(new Date());
| this.setProcessInstance(processInstance);
| this.setToken(processInstance.getRootToken());
| }
|
| @Override
| public boolean execute(JbpmContext jbpmContext) throws Exception {
|
| ProcessInstance processInstance = this.getProcessInstance();
| processInstance.signal();
| jbpmContext.save(processInstance);
| return true;
| }
|
|
then i created a hibernate mapping file
|
| <hibernate-mapping auto-import="false" default-access="field">
|
| <subclass name="foo.bar.AsyncProcessSignalJob"
| discriminator-value="P"
| extends="org.jbpm.job.Job">
|
| </subclass>
|
| </hibernate-mapping>
|
which must be included in jbpm.hibernate.cfg.xml.
once i have created (but not signaled) a process instance i can schedule it like this:
| public void signalAsync(ProcessInstance processInstance, JbpmContext jbpmContext) {
| AsyncProcessSignalJob job = new AsyncProcessSignalJob(processInstance);
| jbpmContext.getJobSession().saveJob(job);
| }
|
|
does this look reasonable? have i overlooked something? i'm still in early testing phase so i cannot guarantee that this code really runs stable.
any comments would be appreciated.
kind regards,
oliver
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4237861#4237861
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4237861
17 years, 1 month