13 Replies Latest reply on Jan 22, 2012 2:08 AM by Prashanth Karnam

    jbpm 5.2 support for XOR gateway and complex gateway.

    Prashanth Karnam Newbie

      Hi All,

       

           I am trying to create a sample workflow based on a business process. I am getting exception as "could not parse knowledge" when i have anything other than a parallel gateway ( ie for only parallel gateway there are no errors , for rest all gateways there are errors ) it gives error. The examples provided by jbpm git does the same as below.

       

       

      KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
      kbuilder.add(ResourceFactory.newClassPathResource("looping/Looping.bpmn"), ResourceType.BPMN2);
      return kbuilder.newKnowledgeBase();

       

      The only change with my code is that i am using it as below.

       

      kbuilder.add(ResourceFactory.newUrlResource(url),

                          ResourceType.BPMN2);

       

      Is there a problem with this or the other gateways are still not supported ? If they are supported then any idea why "kbuilder.newKnowledgeBase();" throws "could not parse knowledge" exception.

       

      Regards

      Prashanth Karnam

        • 1. Re: jbpm 5.2 support for XOR gateway and complex gateway.
          Esteban Aliverti Master

          Could you please share the full stacktrace of the exception? In the case of XOR gateways, how are you defining the condition of the branches? How are you modeling your processes? Are you using eclipse, guvnor, or are you ding them manually in plain xml?

          As far as I know, complex gateways are not supported by jbpm5. The supported gateway types are: Parallel (AND), Inclusive (OR) and Exclusive (XOR).

          • 2. Re: jbpm 5.2 support for XOR gateway and complex gateway.
            Prashanth Karnam Newbie

            Hi Esteban,

             

            I am using Data based XOR gateway. The condition for the branches are defined in Java. The modeling is done in guvnor ( oryx ).

             

            the stack trace of the problem is as below , this is hit as one of the methods containing kbuilder.newKnowledgeBase() is hit. the bpmn is attached herewith.

             

            java.lang.IllegalArgumentException: Could not parse knowledge.

                 ...

                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 org.apache.el.parser.AstValue.invoke(AstValue.java:172)

                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)

                at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)

                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)

                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)

                at javax.faces.component.UICommand.broadcast(UICommand.java:311)

                at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)

                at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)

                at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)

                at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)

                at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)

                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)

                at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

                at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)

                at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)

                at java.lang.Thread.run(Thread.java:619)

            • 3. Re: jbpm 5.2 support for XOR gateway and complex gateway.
              saig0 Newbie

              Your xor data based gateway has the following condition:

               

              return result==true;
              

               

              and references to a variable with name "result".

               

              When you try to deploy this process, you get following message:

               

              Process Compilation error : org.drools.lang.descr.ProcessDescr@1fb6e95
                        SDS/Process_SDS_PrasDemo_0.java (8:320) : result cannot be resolved
                        SDS/Process_SDS_PrasDemo_0.java (14:535) : result cannot be resolved
              

               

              This mean that you forgot to declare the variable in your process.

              • 4. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                Mauricio Salatino Master

                if you want to return true, just do

                return true;

                and not return result = true;

                If you want to assign the variable result, it must be defined in your process as a process variable and then remove the

                return.. because "return result = true" will return always true as the result of the asignation. Unless you want to return the evaluation of the variable with:

                return result == true;

                Cheers

                • 5. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                  Prashanth Karnam Newbie

                  Hi saig,

                   

                      While debugging i do have the variable in processinstance. Does it mean that we need to define this variable in the variable definition of the process while designing in the oryx ?

                   

                       we are adding these variables while starting the process startProcess( , , Map Params ).

                   

                  Hi Mauricio,

                   

                       I am trying to evaluate the value of result==true because in the backend i am having a set of criterias which i evaluate and put the result as true of false into this variable. I want the XOR to branch based on this result value. If its true ( meaning the criterias are met in the backend ) then it should branch one way otherwise the second.

                   

                       Hence i chose condition expression as java and the expression as return result == true;

                   

                       For the senario explained above can you please let me know what is the way of defining the process / condition in Oryx ?

                   

                  Regards

                  Prashanth Karnam

                  • 6. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                    Maciej Swiderski Master

                    After quick look at you bpmn file it looks like you are using parallel (AND) gateway rather than exclusive (XOR) gateway. Maybe that is the problem...

                     

                    HTH

                    • 7. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                      Prashanth Karnam Newbie

                      i had just changed it to parallel while testing. it fails if i make it XOR.

                       

                      Regards

                      Prashanth Karnam

                      • 8. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                        Maciej Swiderski Master

                        You need to declare process variables(properties) in your process to be able to use them:

                         

                        ...
                          <bpmn2:itemDefinition id="_xItem" structureRef="java.lang.Boolean"/>
                          <bpmn2:process id="PrasDemo" drools:packageName="SDS" name="PrasDemo" isExecutable="true">
                            <bpmn2:property id="result" itemSubjectRef="_xItem"/>
                        ...
                        

                         

                        that should do the trick and your XOR gateway will work properly.

                         

                        HTH

                        • 9. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                          Prashanth Karnam Newbie

                          Thanks Maciej , it works. I was adding process variable from the code. In the bpmn i am using variable result which obviously at the bpmn parse time it would not know. I declared the variable in the variable definition of the process and it worked.

                           

                          Regards

                          Prashanth

                          • 10. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                            Prashanth Karnam Newbie

                            Hi All,

                             

                                I have one doubt can you please help me out. I am declaring a process variable as result:Boolean in the bpmn. now when in one of step before the gateway i am setting this process variable as true in the code and passing it through taskclient.complete.

                             

                            result = Boolean.TRUE;
                            } else {
                            result = Boolean.FALSE;
                            }
                            }
                            }

                             

                            ContentData contentData = null;
                            ByteArrayOutputStream bos = new ByteArrayOutputStream();
                            ObjectOutputStream out;

                             

                            out = new ObjectOutputStream(bos);
                            out.writeObject(result);
                            out.close();
                            contentData = new ContentData();
                            contentData.setContent(bos.toByteArray());
                            contentData.setAccessType(AccessType.Inline);

                             

                            taskClient.complete(userTaskDetails.getTaskId(), userid, contentData,
                            bTaskOperationRespHandler);
                            bTaskOperationRespHandler.waitTillDone(1000);

                             

                            the jbpm maps the result to the result of the process variable ? or we need to define this explicitly somewhere in the bpmn ??

                             

                            regards

                            Prashanth Karnam

                            • 11. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                              Esteban Aliverti Master

                              You have to explicitly map the output in the Human Task.

                              • 12. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                                Prashanth Karnam Newbie

                                in the DataOutputSet in oryx for the task node i set as {result=result} which is result process variable to the result data sent from the task complete. Still it is not working. any idea please ???

                                 

                                rather can you please describe the way to define mapping ?

                                • 13. Re: jbpm 5.2 support for XOR gateway and complex gateway.
                                  Prashanth Karnam Newbie

                                  Hi All,

                                   

                                  Thanks Guys for all the help . I am able to get the XOR gateway work with result coming from backend code. Just to mention it so that it helps others

                                   

                                  1. Define the process variable in the variable definition in Oryx for the process.

                                  2. Click on the task where the result variable is to be mapped to the process variable.

                                  3. Click on the DataOutputSet in the properties and enter "Result"

                                  4. Click on the Assigments in the properties and enter "Result-> <the process variable you have defined> "

                                   

                                  and thats it. the result returned as ContentData from the Task Client will be mapped to the process variable.   

                                   

                                  Prashanth Karnam