[jboss-user] [jBPM Users] - Re: [JBPM4 Error]Getting error while 2 tasks are created on

nilspreusker do-not-reply at jboss.com
Tue Oct 27 12:40:26 EDT 2009


I've verified this problem, it occurs when two subsequent tasks are both assigned to the same person and the second one contains a notification node. When the first task is completed, the MailListener will use the findTaskByExecution method of DbSessionImpl.java, which in turn queries the database for tasks by execution. This causes the NonUniqueResult exception, as there are more tasks associated with the execution. See test case below:

=== Environment ==============================
- jBPM Version : 4.1
- Database : MySQL 5 or HSQL
- JDK : Java 6 on Mac OS X Snow Leopard
- Container : java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-219)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-90, mixed mode)
- Configuration : standard config file
- Libraries : standard jbpm setup

=== Process ==================================
<?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process name="MultipleTasks" xmlns="http://jbpm.org/4.0/jpdl">
  |    <start name="start1" g="38,16,48,48">
  |       <transition name="to task1" to="task1" g="-48,-19"/>
  |    </start>
  |    <task name="task1" g="16,96,92,52" assignee="johndoe">
  |       <transition name="to task2" to="task2" g="-48,-19"/>
  |    </task>
  |    <task name="task2" g="16,180,92,52" assignee="johndoe">
  |       <notification/>
  |       <transition name="to end1" to="end1" g="-46,-19"/>
  |    </task>
  |    <end name="end1" g="38,264,48,48"/>
  | 
  | </process>

=== API ===================================
package org.jbpm.examples.task.multiple;
  | 
  | import java.util.List;
  | 
  | import org.jbpm.api.task.Task;
  | import org.jbpm.test.JbpmTestCase;
  | import org.subethamail.wiser.Wiser;
  | 
  | public class MultipleTasksTest extends JbpmTestCase {
  | 
  | 	Wiser wiser = new Wiser();
  | 	String deploymentId;
  | 
  | 	protected void setUp() throws Exception {
  | 		super.setUp();
  | 
  | 		// deploy the process definition
  | 		deploymentId = repositoryService.createDeployment()
  | 				.addResourceFromClasspath(
  | 						"org/jbpm/examples/task/multiple/process.jpdl.xml")
  | 				.deploy();
  | 
  | 		// create actor
  | 		identityService.createUser("johndoe", "John", "Doe", "john at doe");
  | 
  | 		// start mail server
  | 		wiser.setPort(2525);
  | 		wiser.start();
  | 	}
  | 
  | 	protected void tearDown() throws Exception {
  | 		// stop mail server
  | 		wiser.stop();
  | 		repositoryService.deleteDeploymentCascade(deploymentId);
  | 		super.tearDown();
  | 	}
  | 
  | 	public void testOltWorkflow() {
  | 		executionService.startProcessInstanceByKey("MultipleTasks");
  | 
  | 		List<Task> taskList = taskService.findPersonalTasks("johndoe");
  | 		assertEquals(1, taskList.size());
  | 		Task task = taskList.get(0);
  | 		assertEquals("task1", task.getName());
  | 		assertEquals("johndoe", task.getAssignee());
  | 
  | 		// submit the task
  | 		taskService.completeTask(task.getId(), "to task2"); /*This is where it goes wrong...*/
  | 
  | 		// verify that the next task is active and has been assigned to
  | 		// 'johndoe'
  | 		taskList = taskService.findPersonalTasks("johndoe");
  | 		assertEquals(1, taskList.size());
  | 		task = taskList.get(0);
  | 		assertEquals("task2", task.getName());
  | 		assertEquals("johndoe", task.getAssignee());
  | 	}
  | 
  | }

=== Stacktrace ==============================
org.hibernate.NonUniqueResultException: query did not return a unique result: 2
	at org.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:844)
	at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)
	at org.jbpm.pvm.internal.hibernate.DbSessionImpl.findTaskByExecution(DbSessionImpl.java:383)
	at org.jbpm.jpdl.internal.activity.MailListener.notify(MailListener.java:50)
	at org.jbpm.pvm.internal.model.op.ExecuteEventListener.perform(ExecuteEventListener.java:81)
	at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:637)
	at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:597)
	at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:398)
	at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:384)
	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:597)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
	at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_4.signal(ExecutionImpl_$$_javassist_4.java)
	at org.jbpm.pvm.internal.task.TaskImpl.complete(TaskImpl.java:194)
	at org.jbpm.pvm.internal.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:60)
	at org.jbpm.pvm.internal.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:32)
	at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
	at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
	at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:46)
	at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
	at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:96)
	at org.jbpm.examples.task.multiple.MultipleTasksTest.testOltWorkflow(MultipleTasksTest.java:47)
	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:597)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
	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:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

=== Debug logs ==============================

=== Problem description =========================
Problem occurs when two subsequent tasks are both assigned to the same person and the second one contains a notification node

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262469#4262469

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262469



More information about the jboss-user mailing list