6 Replies Latest reply on Nov 22, 2005 8:14 PM by Olivier Kloss

    Assignment in jBPM is so troublesome - urgent help needed!

    Gerhard Wittwer Newbie


      Slowly I'm getting sick about the assignment stuff in jBPM. I'm testing and (re-)searching and changing since hours (may be days).

      Please help me with the following. It must work end of this week for the thesis:

      I have an Identity Module:
      User & Group (and Roles, not used for Assignment).

      Further I have an AssignmentHandler adapted from the ExpressionAssignmentHandler of jBPM.

      Does someone of you have an implementation which is working with User, Group Assignment (ActorId and PooledActor?)?

      I'm doing the following:
      1. Starting new ProcessInstance
      2. On start I create all SwimlaneInstance (forum topic of brittm, see code below)
      3. Editing the taskinstance
      4. Save & close the taskinstance
      5. First Assignment works
      6. edit new task and save & close it
      7. Assignment is NULL.

      I don't know what to do next?
      What's the problem and how could I fix it?
      How can I get the open TaskInstances for the Logged-In User "Mario XYZ" when his swimlane name is "Mario"?
      I tested 10 different versions and tried to log/debug the stuff. I'm out of order now :-)

      Need your help!


      On Start new Process I'm doing the following (like brittm wrote in the forum):

      //create swimlane instances
       log.debug("create swimlane instances");
       Map swimlanes = processDefinition.getTaskMgmtDefinition().getSwimlanes();
       log.debug("swimlanes map: "+ swimlanes.size());
       Iterator itr = swimlanes.keySet().iterator();
       while(itr.hasNext()) {
       Swimlane swimlane = (Swimlane)swimlanes.get(itr.next());
       log.debug("swimlane id="+swimlane.getId()+ " name="+swimlane.getName());
       SwimlaneInstance swi = processInstance.getTaskMgmtInstance().getInitializedSwimlaneInstance(new ExecutionContext(processInstance.getRootToken()), swimlane);
       log.debug("swimlane instance name: "+swi.getName());
       if(swi != null)
       log.warn("swimlane instance is null!");
       Delegation del = swimlane.getAssignmentDelegation();
       if(del == null)
       log.error("swimlane delegation is null, sw name: "+ swimlane.getName());
       String conf = del.getConfiguration();
       log.debug("assignment configuration: " + conf);
       Class cl = ExpressionAssignmentHandler.getExpressionType(conf);
       String name = ExpressionAssignmentHandler.getContentOfAssignment(conf);
       log.debug("name of expression: "+ name);
       if(cl == User.class)
       log.debug("expression is type of user, set actorId");
       else if (cl == Group.class)
       log.debug("expression is type of group, set pooledActors");
       IdentitySession is = new IdentitySession();
       log.debug("get group for name: "+name);
       Group g = is.getGroupByName(name);
       if(g == null)
       log.error("group is null, name: "+name);
       Set users = g.getUsers();
       ArrayList userNames = new ArrayList();
       for(Iterator i = users.iterator();i.hasNext();)
       User u = (User)i.next();
       // create new pooled actor and add it to list
       log.debug("create pooled actor: "+u.getName());
       userNames.add(new PooledActor(u.getName()));

      The log of the assignment handler is the following:

      21:09:49,805 DEBUG [ProcessBean] processInstance: id=14
      21:09:49,806 DEBUG [ProcessBean] create swimlane instances
      21:09:49,806 DEBUG [ProcessBean] swimlanes map: 4
      21:09:49,806 DEBUG [ProcessBean] swimlane id=9 name=Mario
      21:09:49,816 DEBUG [ExpressionAssignmentHandler] assign called
      21:09:49,817 DEBUG [ExpressionAssignmentHandler] assinable:org.jbpm.taskmgmt.exe.SwimlaneInstance@4ddc27
      21:09:49,817 DEBUG [ExpressionAssignmentHandler] expression: user(Mario Andenmatten)
      21:09:49,818 DEBUG [ExpressionAssignmentHandler] resolving first term 'user(Mario Andenmatten)'
      21:09:49,818 DEBUG [ExpressionAssignmentHandler] assignment userName: Mario Andenmatten
      21:09:49,819 DEBUG [ExpressionAssignmentHandler] get username by name: Mario Andenmatten
      21:09:49,855 DEBUG [ExpressionAssignmentHandler] assignment entityname: Mario Andenmatten
      21:09:49,856 DEBUG [ExpressionAssignmentHandler] entity is user : Mario Andenmatten
      21:09:49,857 DEBUG [ProcessBean] swimlane instance name: Mario
      21:09:49,858 DEBUG [ProcessBean] swimlane instance actor id: Mario Andenmatten
      21:09:49,858 DEBUG [ProcessBean] swimlane id=10 name=Diplom
      21:09:49,865 DEBUG [ExpressionAssignmentHandler] assign called
      21:09:49,866 DEBUG [ExpressionAssignmentHandler] assinable:org.jbpm.taskmgmt.exe.SwimlaneInstance@35e7d8
      21:09:49,866 DEBUG [ExpressionAssignmentHandler] expression: group(Diplomanden)
      21:09:49,866 DEBUG [ExpressionAssignmentHandler] resolving first term 'group(Diplomanden)'
      21:09:49,867 DEBUG [ExpressionAssignmentHandler] assignment groupName: Diplomanden
      21:09:49,867 DEBUG [ExpressionAssignmentHandler] get group by name: Diplomanden
      21:09:49,876 DEBUG [ExpressionAssignmentHandler] assignment entityname: Diplomanden
      21:09:49,878 DEBUG [ExpressionAssignmentHandler] create pooled actor: Mario Andenmatten
      21:09:49,879 DEBUG [ExpressionAssignmentHandler] create pooled actor: Gerhard Wittwer
      21:09:49,879 DEBUG [ExpressionAssignmentHandler] entity is group : Diplomanden
      21:09:49,880 DEBUG [ProcessBean] swimlane instance name: Diplom
      21:09:49,880 DEBUG [ProcessBean] swimlane instance actor id: null
      21:09:49,880 DEBUG [ProcessBean] swimlane id=11 name=Project
      21:09:49,883 DEBUG [ExpressionAssignmentHandler] assign called
      21:09:49,884 DEBUG [ExpressionAssignmentHandler] assinable:org.jbpm.taskmgmt.exe.SwimlaneInstance@27ab64
      21:09:49,884 DEBUG [ExpressionAssignmentHandler] expression: group(Projektbeteiligten)
      21:09:49,884 DEBUG [ExpressionAssignmentHandler] resolving first term 'group(Projektbeteiligten)'
      21:09:49,885 DEBUG [ExpressionAssignmentHandler] assignment groupName: Projektbeteiligten
      21:09:49,885 DEBUG [ExpressionAssignmentHandler] get group by name: Projektbeteiligten
      21:09:49,890 DEBUG [ExpressionAssignmentHandler] assignment entityname: Projektbeteiligten
      21:09:49,892 DEBUG [ExpressionAssignmentHandler] create pooled actor: Mario Andenmatten
      21:09:49,892 DEBUG [ExpressionAssignmentHandler] create pooled actor: Walter Eich
      21:09:49,893 DEBUG [ExpressionAssignmentHandler] create pooled actor: Joachim Fulde
      21:09:49,893 DEBUG [ExpressionAssignmentHandler] create pooled actor: Rolf Jufer
      21:09:49,893 DEBUG [ExpressionAssignmentHandler] create pooled actor: Gerhard Wittwer
      21:09:49,894 DEBUG [ExpressionAssignmentHandler] entity is group : Projektbeteiligten
      21:09:49,894 DEBUG [ProcessBean] swimlane instance name: Project
      21:09:49,894 DEBUG [ProcessBean] swimlane instance actor id: null
      21:09:49,894 DEBUG [ProcessBean] swimlane id=12 name=Gerhard
      21:09:49,897 DEBUG [ExpressionAssignmentHandler] assign called
      21:09:49,898 DEBUG [ExpressionAssignmentHandler] assinable:org.jbpm.taskmgmt.exe.SwimlaneInstance@d1c3c
      21:09:49,898 DEBUG [ExpressionAssignmentHandler] expression: user(Gerhard Wittwer)
      21:09:49,898 DEBUG [ExpressionAssignmentHandler] resolving first term 'user(Gerhard Wittwer)'
      21:09:49,899 DEBUG [ExpressionAssignmentHandler] assignment userName: Gerhard Wittwer
      21:09:49,899 DEBUG [ExpressionAssignmentHandler] get username by name: Gerhard Wittwer
      21:09:49,931 DEBUG [ExpressionAssignmentHandler] assignment entityname: Gerhard Wittwer
      21:09:49,931 DEBUG [ExpressionAssignmentHandler] entity is user : Gerhard Wittwer
      21:09:49,931 DEBUG [ProcessBean] swimlane instance name: Gerhard
      21:09:49,931 DEBUG [ProcessBean] swimlane instance actor id: Gerhard Wittwer

      <process-definition name="daworkflow">
       <!-- SWIMLANES (= process roles) -->
       <swimlane name="Project">
       <assignment expression="group(Projektbeteiligten)" />
       <swimlane name="Diplom">
       <assignment expression="group(Diplomanden)" />
       <swimlane name="Mario">
       <assignment expression="user(Mario XYZ)" />
       <swimlane name="Gerhard">
       <assignment expression="user(Gerhard XYZ)" />
      <!-- NODES -->
       <start-state name="Kick Off Meeting durchfuehren">
       <task swimlane="Mario">
       <variable name="comment" />
       <transition to="Pflichtenheft erstellen" />
       <task-node name="Pflichtenheft erstellen">
       <task swimlane="Mario">
       <event type="task-start">
       <action class="hti.aibp.webapp.action.MessageAction">
       <msg4>accountancy application is now informed of the payment</msg4>
       <variable name="comment" />
       <transition name="ok" to="Pflichtenheft Abnahme" />
       <transition name="not ok" to="Voranalyse und Konzept durchfuehren" />
       <task-node name="Pflichtenheft Abnahme">
       <task swimlane="Project">
       <variable name="Variable1" />
       <transition to="Voranalyse und Konzept durchfuehren" />
       <task-node name="Voranalyse und Konzept durchfuehren">
       <task swimlane="Project">
       <variable name="comment" />
       <variable name="Variable1" />
       <transition to="Realisierung beginnen" />
       <task-node name="Realisierung beginnen">
       <task swimlane="Project">
       <variable name="comment" access="read" />
       <variable name="Variable1" />
       <transition name="anda" to="anda" />
       <task-node name="AIBP Client erstellen">
       <task swimlane="Gerhard">
       <variable name="comment" access="read" />
       <variable name="Variable1" />
       <transition to="andb" />
       <task-node name="AIBP Webservice erstellen">
       <task swimlane="Mario">
       <variable name="comment" access="read" />
       <variable name="Variable1" />
       <transition to="andb" />
       <task-node name="AIBP Webapp erstellen">
       <task swimlane="Mario">
       <variable name="comment" access="read" />
       <variable name="Variable1" />
       <transition to="andb" />
       <task-node name="Abschluss Phase Realisierung">
       <task swimlane="Mario">
       <variable name="comment" />
       <transition to="Ende Diplomarbeit" />
       <fork name="anda">
       <transition name="a" to="AIBP Client erstellen" />
       <transition name="b" to="AIBP Webservice erstellen" />
       <transition name="c" to="AIBP Webapp erstellen" />
       <join name="andb">
       <transition to="Abschluss Phase Realisierung" />
       <end-state name="Ende Diplomarbeit" />

        • 1. Re: Assignment in jBPM is so troublesome - urgent help neede
          Ronald van Kuijk Master

          I think I've mentioned this once. but nobody replied or confirmed, but if you use swimlanes, the firs time an task with this swimlane is assigned, it works. The second time it goes wrong. Try it by adding a

           <swimlane name="Mario2">
           <assignment expression="user(Mario XYZ)" />

          and a Mario3 etc and have each task uniquely refer to one of these swimlanes. Then it everything goes fine. I thought I commented on a jira issue about this, but do not seem to be able to find it anymore. Another solution is to put the assignment directly in the task and not use a swimlane.

          If this indeed solves your problem, file a jira issue for this and refer to this post.

          • 2. Re: Assignment in jBPM is so troublesome - urgent help neede
            Ronald van Kuijk Master

            Sjeez, what a typos. You can see I was almost sleeping. Or paraphrasing TAFKAP (let's not start singing it...) I was dreaming when I wrote this, forgive me if it goes astray.

            • 3. Re: Assignment in jBPM is so troublesome - urgent help neede
              kamaljeet sandhu Newbie

              Though I am just arriving at these issues now ( after a long chase of getting own identity module spring-jbpm integration) ,
              I have seen issues with loading a task instance in one session and using/assigning it etc. in another session.

              In fact a loadTaskInstance call really loads near about half the db tables thru joins and using this in subsequent hibernate ( jbpmsession) sessions is very dicey(for me)

              Hope this helps or I may be really off...

              • 4. Re: Assignment in jBPM is so troublesome - urgent help neede
                Ronald van Kuijk Master

                hmmm... don't think this is related. Even if I do it in the same session it fails. Realy seems assignment/swimlane related. But you never know.

                • 5. Re: Assignment in jBPM is so troublesome - urgent help neede
                  Gerhard Wittwer Newbie

                  @ kukeltje

                  I've tried this 100 times :-) It works how you wrote it. First time no problem, second time BANG...

                  I worked nearly 25 hours on that problem. Now I give up. I do it like this:
                  The swimlane name always must match the assignment name. Then it works (with an implemented workaround...)

                  It's not nice to do workarounds in the own businesslogic to correct the jbpm bugs. But I know, I can help (if I have time for this.. :)

                  Question: How works the "direct" assignment for the task? Could you please post a sample jPDL XML and a short description how to handle this in the AssignmentHandler?

                  The Assignment Assassin

                  • 6. Re: Assignment in jBPM is so troublesome - urgent help neede
                    Olivier Kloss Newbie

                    Let me tell you I know what you've been through.
                    You can make a very simple assignment mechanism with (and thanks to) delegations (see the user guide).
                    You just need to create a class that implements AssignementHandler and that has the fields you need to determine how to assign the task:

                    public class MyAssignmentClass implements AssignmentHandler {
                     String myFieldA;
                     String myFieldB;
                     public void assign(Assignable assignable, ExecutionContext executionContext) {

                    Then in your processdefinition, for each task, you just need to add a little assignment blurb like this:
                     <assignment class="com.mypackage.MyAssignmentClass">

                    So everytime a task is instantiated, a MyAssignmentClass object is created and its classFieldA and classFieldB (and other fields) are initialized with your values and the assign() method is called.
                    Now you have everything you need to assign the task: your values, an Assignable and the ContextInstance.
                    After that it's up to you as it all depends on how your app is designed.
                    Refer to the user guide's assignment and delegation sections (if you haven't read it 10 times already ; ), all the basics are there. If its well explained enough for a bird brain like me to understand than it shouldn't be hard for anyone : ).