3 Replies Latest reply on May 21, 2014 4:28 AM by akoskm

    HumanTaskExample exception in example

    akoskm Newbie

      Hello!

       

      I'm trying to run a process which contains a Human Task. I set up the following example

      jbpm/jbpm-examples/src/main/java/org/jbpm/examples/humantask/HumanTaskExample.java at master · droolsjbpm/jbpm · GitHub

      and put jbpm/jbpm-examples/src/main/resources/humantask/HumanTask.bpmn at master · droolsjbpm/jbpm · GitHub into my classpath.

       

      HumanTaskExample reaches line 70:

       

      TaskSummary task4 = taskService.getTasksAssignedAsPotentialOwner("sales-rep", "en-UK").get(0);
      
      

       

      where it suddenly throws a NPE.


      Here is the complete output of this program:

      Sales-rep executing task Review(473: )
      krisv executing task User Approval(474: )
      john executing task Manager Approval(475: )
      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:635)
        at java.util.ArrayList.get(ArrayList.java:411)
        at org.mycompany.test.jbpm.HumanTaskExample.main(HumanTaskExample.java:70)
      
      

       

      Any idea why the example in your master branch doesn't work?

        • 1. Re: HumanTaskExample exception in example
          Mauricio Salatino Master

          Hmm, that's weird. I manage to reproduce the issue here so I will take a look on it.

          Basically it is failing because it is not a test, where we can detect if something gets broken.

          The error is quite clear, there is no task for "sales-rep", the question is why???

          1 of 1 people found this helpful
          • 2. Re: Re: HumanTaskExample exception in example
            akoskm Newbie

            I'm relatively new to Human Task but as far as I understand Review task is assigned to the group: sales, this contains one person: sales-rep.

            The User Approval task contains ActorId=#{userId} which is set to krisv, the Manager Approval task is assigned to the group PM. This group contains one user: john.

             

            However I don't see that the Notification task is assigned to any group or person, so I set the GroupId to sales and I expected that the line

            TaskSummary task4 = taskService.getTasksAssignedAsPotentialOwner("sales-rep", "en-UK").get(0);
            
            
            

             

            will return Notification task but it didn't.

             

            EDIT

            --------------------

            (forum won't allow me to create a new post)


            As I posted above the Notification User task in the HumanTask.bpmn example has no ActorId or GroupId defined. I tried to set one of these through the BPMN2 Process Editor but apparently the editor isn't saved my changes.

            When I manually inserted the

             

                 <potentialOwner>
                    <resourceAssignmentExpression>
                      <formalExpression>sales-rep</formalExpression>
                    </resourceAssignmentExpression>
                  </potentialOwner>
            
            

             

            to the declaration of Notification user task the example program completed, here is the full output:

             

            Sales-rep executing task Review(595: )
            krisv executing task User Approval(596: )
            john executing task Manager Approval(597: )
            sales-rep executing task Notification(598: )
            resultUser = Agree
            result = Accept
            ActorId = sales-rep
            SwimlaneActorId = sales-rep
            resultManager = Agree
            description = Need a new laptop computer
            userId = krisv
            date = Tue May 20 11:48:00 CEST 2014
            comment = Agreed, existing laptop needs replacing
            TaskName = Request Notification
            NodeName = Notification
            Process instance completed
            
            

             

            I can create a pull request in github with the corrected example.

            • 3. Re: Re: HumanTaskExample exception in example
              akoskm Newbie

              For anyone who's interested, Mauricio said that the assignment should work because of the lane which contains the notification task. I already created a pull request which contains the above modification, you can follow the discussion here:

              https://github.com/droolsjbpm/jbpm/pull/203