[jboss-user] [jBPM Users] - Re: Signaling executions for processes that containt tasks d
LMarinkov
do-not-reply at jboss.com
Fri Sep 11 09:04:23 EDT 2009
The error that occurs is:
org.hibernate.NonUniqueResultException: query did not return a unique result: 2
If you have check out the 4.1 branch from svn. Just replace the state in the process definition with task and then run:
mvn -Dtest="SignalExecutionTest" test
As you requested below is shown the full code for the shortest test(AvgDurationTest):
package org.jbpm.test.history;
| import java.util.Map;
|
| import org.jbpm.api.Execution;
| import org.jbpm.test.JbpmTestCase;
|
|
| public class AvgDurationTest extends JbpmTestCase {
|
| public void testAvgDuration() throws Exception {
| deployJpdlXmlString(
| "<process name='Insurance claim' key='ICL'>" +
| " <start>" +
| " <transition to='one' />" +
| " </start>" +
| " <task name='one'>" +
| " <transition to='two' />" +
| " </task>" +
| " <task name='two'>" +
| " <transition to='three' />" +
| " </task>" +
| " <task name='three'>" +
| " <transition to='end' />" +
| " </task>" +
| " <end name='end' />" +
| "</process>"
| );
|
| executeProcess();
| executeProcess();
| executeProcess();
|
| Map<String, Long> avgDurations = historyService.avgDurationPerActivity("ICL-1");
|
|
| Long avgDurationOne = avgDurations.get("one");
| assertNotNull(avgDurationOne);
| assertTrue("expected avg duration bigger then 40, but was"+avgDurationOne, avgDurationOne>40);
| Long avgDurationTwo = avgDurations.get("two");
| assertNotNull(avgDurationTwo);
| assertTrue("expected avg duration bigger then 10, but was"+avgDurationTwo, avgDurationTwo>10);
| Long avgDurationThree = avgDurations.get("three");
| assertNotNull(avgDurationThree);
| assertTrue("expected avg duration bigger then 0, but was"+avgDurationThree, avgDurationThree>=0);
|
| assertEquals(3, avgDurations.size());
| }
|
| protected void executeProcess() throws InterruptedException {
| Execution execution = executionService.startProcessInstanceByKey("ICL");
| Thread.sleep(50);
| executionService.signalExecutionById(execution.getId());
| Thread.sleep(20);
| executionService.signalExecutionById(execution.getId());
| executionService.signalExecutionById(execution.getId());
| }
|
| }
Logging output in eclipse console with logging set to org.jbpm.level=FINE
12:20:41,500 FIN | [BaseJbpmTestCase] === starting testSignalExecutionById =============================
| 12:20:44,559 FIN | [ProcessDefinitionImpl] creating new execution for process 'Insurance claim'
| 12:20:44,567 FIN | [DefaultIdGenerator] generated execution id ICL.82436
| 12:20:44,577 FIN | [ExecuteActivity] executing activity(18662247)
| 12:20:44,578 FIN | [ExecuteActivity] executing activity(a)
| 12:20:44,600 FIN | [Signal] signalling activity(a), signalName=null
| 12:20:44,605 FIN | [ExecuteActivity] executing activity(b)
| 12:20:44,624 FIN | [Signal] signalling activity(b), signalName=null
| ### EXCEPTION ###########################################
| 12:20:44,627 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.SignalCmd at b48b11
| 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.TaskActivity.signal(TaskActivity.java:116)
| at org.jbpm.jpdl.internal.activity.TaskActivity.signal(TaskActivity.java:102)
| at org.jbpm.pvm.internal.model.op.Signal.perform(Signal.java:68)
| 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.cmd.SignalCmd.execute(SignalCmd.java:61)
| at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)
| 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.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:84)
| at com.cg.wfl.jbpm.examples.wfl_examples.execution.SignalExecutionTest.testSignalExecutionById(SignalExecutionTest.java:38)
| 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:154)
| at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
| at junit.framework.TestCase.runBare(TestCase.java:127)
| 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:118)
| at junit.framework.TestSuite.runTest(TestSuite.java:208)
| at junit.framework.TestSuite.run(TestSuite.java:203)
| 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)
| ### EXCEPTION ###########################################
| 12:20:44,636 SEV | [BaseJbpmTestCase]
| ### EXCEPTION ###########################################
| 12:20:44,636 SEV | [BaseJbpmTestCase] TEST THROWS EXCEPTION: query did not return a unique result: 2
| 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.TaskActivity.signal(TaskActivity.java:116)
| at org.jbpm.jpdl.internal.activity.TaskActivity.signal(TaskActivity.java:102)
| at org.jbpm.pvm.internal.model.op.Signal.perform(Signal.java:68)
| 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.cmd.SignalCmd.execute(SignalCmd.java:61)
| at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)
| 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.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:84)
| at com.cg.wfl.jbpm.examples.wfl_examples.execution.SignalExecutionTest.testSignalExecutionById(SignalExecutionTest.java:38)
| 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:154)
| at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
| at junit.framework.TestCase.runBare(TestCase.java:127)
| 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:118)
| at junit.framework.TestSuite.runTest(TestSuite.java:208)
| at junit.framework.TestSuite.run(TestSuite.java:203)
| 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)
| ### EXCEPTION ###########################################
| 12:20:44,637 SEV | [BaseJbpmTestCase]
| 12:20:44,670 FIN | [DbSessionImpl] deleting history process instance ICL.82436
| 12:20:44,707 FIN | [DbSessionImpl] deleting process instance ICL.82436
| 12:20:44,718 FIN | [DeleteDeploymentCmd] deleting deployment 1
| 12:20:44,762 FIN | [BaseJbpmTestCase] === ending testSignalExecutionById =============================
|
| 12:20:44,765 FIN | [BaseJbpmTestCase] === starting testSignalExecutionWithVariables =============================
| 12:20:44,806 FIN | [ProcessDefinitionImpl] creating new execution for process 'Insurance claim'
| 12:20:44,810 FIN | [DefaultIdGenerator] generated execution id ICL.82436
| 12:20:44,810 FIN | [ExecuteActivity] executing activity(19679080)
| 12:20:44,811 FIN | [ExecuteActivity] executing activity(a)
| 12:20:44,822 FIN | [Signal] signalling activity(a), signalName=null
| 12:20:44,824 FIN | [ScopeInstanceImpl] create variable 'amount' in 'execution[ICL.82436]' with value '763.74'
| 12:20:44,825 FIN | [ScopeInstanceImpl] create variable 'type' in 'execution[ICL.82436]' with value 'Accident'
| 12:20:44,825 FIN | [ScopeInstanceImpl] create variable 'customer' in 'execution[ICL.82436]' with value 'John Doe'
| 12:20:44,834 FIN | [ExecuteActivity] executing activity(b)
| 12:20:44,869 FIN | [DbSessionImpl] deleting history process instance ICL.82436
| 12:20:44,885 FIN | [DbSessionImpl] deleting process instance ICL.82436
| 12:20:44,891 FIN | [DeleteDeploymentCmd] deleting deployment 2
| 12:20:44,901 FIN | [BaseJbpmTestCase] === ending testSignalExecutionWithVariables =============================
|
| 12:20:44,901 FIN | [BaseJbpmTestCase] === starting testDefaultSignalWithoutTransitions =============================
| 12:20:45,014 FIN | [ProcessDefinitionImpl] creating new execution for process 'p'
| 12:20:45,019 FIN | [DefaultIdGenerator] generated execution id p.3
| 12:20:45,022 FIN | [ExecuteActivity] executing activity(12812631)
| 12:20:45,023 FIN | [ExecuteActivity] executing activity(a)
| 12:20:45,041 FIN | [Signal] signalling activity(a), signalName=null
| 12:20:45,042 FIN | [ExecutionImpl] execution[p.3] ends
| 12:20:45,057 FIN | [DbSessionImpl] deleting process instance p.3
| 12:20:45,059 SEV | [BaseJbpmTestCase]
| ### EXCEPTION ###########################################
| 12:20:45,059 SEV | [BaseJbpmTestCase] ASSERTION FAILURE: null
| junit.framework.AssertionFailedError
| at junit.framework.Assert.fail(Assert.java:47)
| at junit.framework.Assert.assertTrue(Assert.java:20)
| at junit.framework.Assert.assertTrue(Assert.java:27)
| at com.cg.wfl.jbpm.examples.wfl_examples.execution.SignalExecutionTest.testDefaultSignalWithoutTransitions(SignalExecutionTest.java:91)
| 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:154)
| at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
| at junit.framework.TestCase.runBare(TestCase.java:127)
| 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:118)
| at junit.framework.TestSuite.runTest(TestSuite.java:208)
| at junit.framework.TestSuite.run(TestSuite.java:203)
| 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)
| ### EXCEPTION ###########################################
| 12:20:45,059 SEV | [BaseJbpmTestCase]
| 12:20:45,106 FIN | [DeleteDeploymentCmd] deleting deployment 3
| 12:20:45,115 FIN | [BaseJbpmTestCase] === ending testDefaultSignalWithoutTransitions =============================
best regards!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4254752#4254752
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4254752
More information about the jboss-user
mailing list