cancel
Showing results for 
Search instead for 
Did you mean: 

JUnit: execution does not exist

christoph_retti
Champ in-the-making
Champ in-the-making
Hi, I have created my first process as a copy of the groovy examples and when I run the JUnit test with the code


  @Deployment
  public void testMyProcess() {
    
    int[] inputArray = new int[] {1, 2, 3, 4, 5};
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("myProcess", CollectionUtil.singletonMap("inputArray", inputArray));

    for (Execution execution : runtimeService.createExecutionQuery().list()) {
       System.out.println(String.format("[EXECUTION %s] %s", execution.getId(), execution.getProcessInstanceId()));
    }
   
    Integer result = (Integer) runtimeService.getVariable(pi.getId(), "y");
    assertEquals(2, result.intValue());
  }


it fails with

org.activiti.engine.ActivitiException: execution 5 doesn't exist
   at org.activiti.engine.impl.cmd.GetExecutionVariableCmd.execute(GetExecutionVariableCmd.java:49)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.getVariable(RuntimeServiceImpl.java:97)
   at com.braintribe.bpm.samples.DemoTest.testMyProcess(DemoTest.java:22)
   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:168)
   at org.activiti.engine.impl.test.PvmTestCase.runTest(PvmTestCase.java:75)
   at junit.framework.TestCase.runBare(TestCase.java:134)
   at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(AbstractActivitiTestCase.java:89)
   at junit.framework.TestResult$1.protect(TestResult.java:110)
   at junit.framework.TestResult.runProtected(TestResult.java:128)
   at junit.framework.TestResult.run(TestResult.java:113)
   at junit.framework.TestCase.run(TestCase.java:124)
   at junit.framework.TestSuite.runTest(TestSuite.java:232)
   at junit.framework.TestSuite.run(TestSuite.java:227)
   at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
   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)

which is correct because

runtimeService.createExecutionQuery().list()

does not pass anything back.

My question is if I did miss a setting to keep the process alive (I copied all the files from the groovy example and just changed
created a new process myself)?

  regards, Chris

P.S. sorry for asking that simple questions, I am new to the topic
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
Does your process have any 'wait' states in it?

If your process runs from start -> end with only automatic steps, then there will be no runtime process instances (nor executions) in the database (since your process is already done).

christoph_retti
Champ in-the-making
Champ in-the-making
Hi, my process does only contain one scriting and one service task (see the picture below), so everything is automatic.

What can I do so that the process will be persisted between some automatic steps?

  c

frederikherema1
Star Contributor
Star Contributor
The process will only persist when it encounters a wait-state (eg. usertask, signaltask). When the process starts and encounters no wait-states until the end, no trace is left behind in the runtime-database. The history however, will contain a HistoricProcessInstance entry for your process (use the HistoryService)

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
For persistence between automatic steps, vote for ACT-126