0 Replies Latest reply on Jul 18, 2013 10:21 AM by fellowtom

    taskId of user task is cumulating

    fellowtom

      Hi all,

       

       

      this is my first post here, since I'm pretty new with jbpm and bpm in general. Installation worked fine and trying one of the example processes is fine as well.

      So I tried to set up my own process wich just consists of Start->script->user->script->end, to get a little "deeper" training. The code is (almost) the same compared to EvaluationExample2.

      But I just wanted to complete 1 user task, no gateways or anything else. Long sentence short, it works fine ONCE.

      Im using jBPM 6. Here's the code:

       

       

          

      public static void main(String[] args) throws Exception{
                try{
                          RuntimeManager manager = getRuntimeManager("process_1.bpmn");        
                          RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
                          KieSession ksession = runtime.getKieSession();
      
                      // start a new process instance
                          Map<String, Object> params = new HashMap<String, Object>();
                          params.put("worker", "user1");
                          ksession.startProcess("process_1.bpmn", params); 
      
                      // the first task
                          TaskService tser = runtime.getTaskService();
                          TaskSummary tsum = taskService.getTaskAssignedAsPotentialOwner("user1", "en-UK").get(0);
                      System.out.println(tsum.getId());
                      taskService.start(tsum.getId(), "user1");
                          taskService.complete(tsum.getId(), "user1", null);
      
                          manager.disposeRuntimeEngine(runtime);
                     } catch (Throwable t) {
                               t.printStackTrace();
                     }
                     System.exit(0);
                     }
      
                     private static RuntimeManager getRuntimeManager(String process) {
                          // load up the knowledge base
                          JBPMHelper.startH2Server();
                             JBPMHelper.setupDataSource();
                             Properties properties= new Properties();
                          properties.setProperty("krisv", "");
                          properties.setProperty("mary", "HR");
                          properties.setProperty("john", "PM");
                          UserGroupCallback userGroupCallback = new JBossUserGroupCallbackImpl(properties);
                          RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()
                               .userGroupCallback(userGroupCallback)
                               .addAsset(ResourceFactory.newClassPathResource(process), ResourceType.BPMN2)
                               .get();
                          return RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
                     }
       }
      

       

       

      The error is the following: User '[UserImpl: 'user1']' was unable to execution operation 'Start' on task id 4 due to a no 'current status' match.

      So everytime I:

                - change the string of employee (e.g. "user1" to "user2"), it works ONCE again, but the taskId is summating (every time I try to run, its getting taskId++;). BTW the taskId should be 4.

                - delete the jbpm-db.h2.db, it works fine again ONCE, but the taskId starts at 1.

                - run the EvaluationExample2 in between, I can run my process again once. A second time fails (Example runs multiple times), but taskId is always 4 like it should. So this seems to 'reset' my problem.

       

      So I hope I could explain my Problem and I'm sure its a very simple one for you. (probably just a db setup)

       

       

      With kind regards!

      Greetings,

      FellowTom