1 2 Previous Next 17 Replies Latest reply on Nov 28, 2007 1:07 PM by jeffdelong

    Rule Parsing error while adding cutom object information in

    vsahni

      Hi All,
      I am trying to add a custom object such as ErrorList to a JBOSS-ESB message so that as the rules are excuted by rule engine I can update the message with some information such as errors. On following the steps listed below and deploying a rule parser error is thrown.


      1) Action Processor:
      ErrorList errorList = new ErrorList();

      where ErrorList is a class containing ArrayList and a property to add a value to errorlist.
      1) Setup Action Processor:
      ErrorList errorList = new ErrorList();
      message.getBody().add("TheErrorList",errorList);
      2) Updating Message in .drl file as below:
      rule "TEST"
      when
      errors : ErrorList()
      then
      errors.setError("ERROR1");
      Log : test log";
      end
      3) jboss-xml definition where .drl file gets loaded:

      <object-path esb="body.TheErrorList" />



      Error:
      :50:57,130 INFO [STDOUT] Message Property org.jboss.soa.esb.actions.current.a
      er: [B@bf0023
      :50:57,146 WARN [ActionProcessingPipeline] Unexpected exception caught while
      ocessing the action pipeline
      g.jboss.soa.esb.actions.ActionProcessingException: Could not parse the rules.
      g.drools.lang.ExpanderException@116832f
      at org.jboss.soa.esb.actions.ContentBasedWiretap.process(ContentBasedWir
      ap.java:103)
      at org.jboss.soa.esb.actions.ContentBasedRouter.process(ContentBasedRout
      .java:50)
      at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(
      tionProcessingPipeline.java:265)
      at org.jboss.soa.esb.listeners.message.MessageAwareListener$1.run(Messag
      wareListener.java:297)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
      or.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
      ava:675)
      at java.lang.Thread.run(Thread.java:595)
      used by: org.jboss.soa.esb.services.routing.MessageRouterException: Could not
      rse the rules. org.drools.lang.ExpanderException@116832f
      at org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter.rout
      JBossRulesRouter.java:155)
      at org.jboss.soa.esb.actions.ContentBasedWiretap.routeMessage(ContentBas
      Wiretap.java:132)
      at org.jboss.soa.esb.actions.ContentBasedWiretap.process(ContentBasedWir
      ap.java:98)
      ... 6 more
      used by: org.jboss.soa.esb.services.routing.cbr.CBRException: org.drools.lang.
      panderException@116832f
      at org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter.read
      leBase(JBossRulesRouter.java:208)
      at org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter.rout
      JBossRulesRouter.java:126)
      ... 8 more
      used by: org.drools.rule.InvalidRulePackage: org.drools.lang.ExpanderException
      16832f
      at org.drools.rule.Package.checkValidity(Package.java:419)
      at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:2
      )
      at org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter.read
      leBase(JBossRulesRouter.java:205)
      ... 9 more
      :50:57,161 WARN [MessageAwareListener] Error processing courier, backing off
      r 1000 milliseconds

        • 1. Re: Rule Parsing error while adding cutom object information
          kurtstam

          Did you also add an import statement for the ErrorList Object on the drl file?

          • 2. Re: Rule Parsing error while adding cutom object information
            kurtstam

            BTW, can you move this topic to the user forum?

            http://www.jboss.com/index.html?module=bb&op=viewforum&f=246

            thx,

            --Kurt

            • 3. Re: Rule Parsing error while adding cutom object information
              marklittle

              Moved.

              • 4. Re: Rule Parsing error while adding cutom object information
                vsahni

                Kurt,
                Thanks for responding to my issue. Yes I did include the import statement.

                However I am not sure if rule engine is picking up the definition correctly. To validate I tried both statements listed below see if engine detects ErrorList definition or not.

                import com.oldlane.esb.util.ErrorList;
                when
                 e : junknnmnnErrorList()
                or
                when
                 e : ErrorList()


                In both cases it did not make a difference.




                • 5. Re: Rule Parsing error while adding cutom object information
                  vsahni

                  Even a simple syntax such as the one below produces the ExpandException.

                  rule "Missing TradeId Ref "
                  when
                  m : Message ()
                  then
                  Log : "~~~~ Missing TradeId";
                  end

                  Thanks for your help.

                  • 6. Re: Rule Parsing error while adding cutom object information
                    kurtstam

                    Did you deploy this class so Drools can find it? It should be no different then the 'Order' object in most junit and quickstart examples.

                    • 7. Re: Rule Parsing error while adding cutom object information
                      kurtstam

                      Note that 'Log' is not standard Drools language, it is defined in the XPathLanguage.dsl.

                      Also I don't think there is an 'or' construct.

                      • 8. Re: Rule Parsing error while adding cutom object information
                        jeffdelong

                        Can you include the entire contents of the rule file?

                        • 9. Re: Rule Parsing error while adding cutom object information
                          vsahni

                          I am including both rule and dsl file. I am not sure where did you se'or' construct.


                          package com.jboss.soa.esb.routing.cbr;
                          
                          import org.jboss.soa.esb.message.Message;
                          import org.jboss.soa.esb.message.format.MessageType;
                          import com.oldlane.esb.util.ErrorList;
                          
                          #declare any global variables here
                          global java.util.List destinations;
                          expander OLXPathLanguage.dsl
                          
                          rule "Missing TradeId Ref "
                           when
                           m : Message ()
                           then
                           Log("Missing Data");
                          end
                          
                          OLXPathLanguage.dsl definition is:
                          #JBossESB Content Based Routing using XPath DSL
                          [when]xpathMatch "{xpath}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentMatches(msg, "{xpath}") )
                          [when]xpathEquals "{xpath}", "{value}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentEquals(msg, "{xpath}", "{value}") )
                          [when]xpathGreaterThan "{xpath}", "{value}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentGreaterThan(msg, "{xpath}", "{value}") )
                          [when]xpathLessThan "{xpath}", "{value}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( org.jboss.internal.soa.esb.services.routing.cbr.DslHelper.xmlContentLessThan(msg, "{xpath}", "{value}") )
                          [when]xpathDateAfter "{xpath1}", "{xpath2}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( com.oldlane.esb.util.OLDSLHelper.xmlDateAfter(msg, "{xpath1}", "{xpath2}") )
                          [when]xpathDateBefore "{xpath1}", "{xpath2}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( com.oldlane.esb.util.OLDSLHelper.xmlDateBefore(msg, "{xpath1}", "{xpath2}") )
                          [when]xpathEmpty "{xpath}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( com.oldlane.esb.util.OLDSLHelper.xmlContentEmpty(msg, "{xpath}") )
                          [when]xpathValidateAllotment "{xpath}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( com.oldlane.esb.util.OLDSLHelper.validateAllotment(msg, "{xpath}") )
                          [then]Log : "{message}"=System.out.println("{message}");
                          [then]Destination : "{message}"=destinations.add("{message}");
                          
                          


                          • 10. Re: Rule Parsing error while adding cutom object information
                            jeffdelong

                            Could you also post the relevant portion of the jboss-esb.xml, i.e., the contents of the action element for the content based router.

                            • 11. Re: Rule Parsing error while adding cutom object information
                              vsahni

                              Please see the CORRECTED rule file!!! By the way if I comment m : Message() syntax below and uncomment the Xpath line then it works fine.

                              But the goal here is to use syntax such as
                              m : Message() or e : ErrorList() so that a custom object data can be updated in the message.

                              package com.jboss.soa.esb.routing.cbr;

                              import org.jboss.soa.esb.message.Message;
                              import org.jboss.soa.esb.message.format.MessageType;
                              import com.oldlane.esb.util.ErrorList;

                              #declare any global variables here
                              global java.util.List destinations;

                              expander OLXPathLanguage.dsl

                              rule "Missing TradeId Ref "
                              when
                              m : Message()
                              #xpathEmpty "/olcmf/olcmfMessage/messageData/dataRecord/tradeRecord/tradeIDs/tradeID"
                              then
                              Log : "~~~~ Missing TRADE ID";
                              end

                              • 12. Re: Rule Parsing error while adding cutom object information
                                jeffdelong

                                In these examples, you are not writing your rules in the the DSL, you are writing them in native DRL. But your rule file is "expanding" them with the OLXPathLanguage.dsl

                                You would need to add your additional rules mappings to the DSL. For example:

                                [when]There is an ErrorList=errors : ErrorList()
                                [then]Add error to ErrorList= errors.setError("ERROR1");
                                


                                You would then write the rule
                                when
                                 There is an ErrorList
                                then
                                 Add error to ErrorList
                                



                                The DSL also needs to be referenced in the action:
                                 <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
                                 <property name="ruleSet" value="YourRules.drl"/>
                                 <property name="ruleLanguage" value="OLXPathLanguage.dsl"/>
                                


                                • 13. Re: Rule Parsing error while adding cutom object information
                                  vsahni

                                  Sure here is the relevant portion of the esb xml.

                                  <action name="tradeOrSecurityRouter"
                                   class="org.jboss.soa.esb.actions.ContentBasedRouter">
                                   <property name="ruleSet"
                                   value="filename.drl" />
                                   <property name="ruleReload" value="true" />
                                   <property name="ruleLanguage"
                                   value="OLXPathLanguage.dsl" />
                                   <property name="destinations">
                                  
                                   ---- route to some destinations here ......
                                  
                                   </property>
                                   <property name="object-paths">
                                   <object-path esb="body.TheErrorList" />
                                   </property>


                                  • 14. Re: Rule Parsing error while adding cutom object information
                                    jeffdelong

                                    Also, I would be careful about using 'or' between facts. It will make it harder to write your DSL, but also can lead to issues in the consequence of the rule. If you say:

                                    when
                                     m: Message() or e : ErrorList
                                    then
                                     m.doSomething();
                                     e.doSomethingElse();
                                    


                                    You will get an error when either Message or ErrorList does not exist.


                                    1 2 Previous Next