5 Replies Latest reply on Feb 23, 2006 3:23 AM by shriram e

    SubProcessInstance(s) returns  null

    shriram e Newbie

      Hi,

      I have multiple subProcesses in my ProcessDefinition and I need to get the SubProcessInstance.

      I tried using the method ,

      processInstance.getRootToken().getSubProcessInstance();

      The method returns subProcessInstance when i have single sub-process in my process definition.
      But it returns null, when i have multiple sub-processes in the process defintion.

      Is there any other way i can get the subProcessInstance(s) in the above case ?

      Thanks in Adv
      Shriram

        • 1. Re: SubProcessInstance(s) returns  null
          Tom Baeyens Master

          this is a known bug. it requires a mapping and db schema change to fix this. so it's not solved in 3.0.2.

          but it is solved in 3.1

          regards, tom.

          • 2. Re: SubProcessInstance(s) returns  null
            shriram e Newbie

            Hi Tom,

            Thanks for your reply.
            Iam currently working in JBPM 3.1 release. But the method

            processInstance.getRootToken().getSubProcessInstance();

            still returns null, when i have multiple sub-processes in process defintion.

            Is the bug still open? Is there any other method available for getting the subProcessInstances?


            Thanks in Advance
            Shriram

            • 3. Re: SubProcessInstance(s) returns  null
              shriram e Newbie

              Could anybody say is there other way to get the subProcessInstances
              from mainProcessInstance.

              As this stops completely from using the multiple subProcess in the processdefintion file, as subProcessInstances returns null.

              Thanks
              Shriram


              • 4. Re: SubProcessInstance(s) returns  null
                Ian Terrell Newbie

                Shriram,

                I am successfully using both multiple subprocesses AND .getSubProcessInstance(), so I doubt that's the issue.

                Are the SubProcessInstanceIDs getting set in the database? Look at the values manually to tell. If they are null, make sure that you are saving the process instances you create and you are correctly closing the jbpmContext.

                Please post your process definition and java code if you need more help and I'll take a look at it.

                Ian

                • 5. Re: SubProcessInstance(s) returns  null
                  shriram e Newbie

                  Hi Ian,

                  Thanks for your reply.

                  I got it working now. Yes, The subProcessInstance IDs are stored in DB.

                  Actually my Process has two subProcesses. The call

                  processInstance.getRootToken.getActiveChildren().
                  gives me a map of tokens in the mainProcess. From the token in map,
                  i say token.SubProcessInstance()-> which returned me the subProcessInstances.

                  I paste here the code , so that it might be useful for others, who needs subProcessInstances.

                  Token rootToken = process_Instance.getRootToken();
                  HashMap collMap = (HashMap)rootToken.getActiveChildren();
                  Collection colln = collMap.values();
                  Iterator iter = colln.iterator();
                  while (iter.hasNext()) {
                  Token token = (Token) iter.next();
                  ProcessInstance subPI = token.getSubProcessInstance();
                  System.out.println( " SUBPI ID :>>>> " + subPI.getId());
                  }



                  This will return all the child subProcessInstances of the parent ProcessInstance.

                  hope it helps !!!

                  tHANKS
                  Shriram