ambiguity with 'end' keyword and end() method in drl file

39 views
Skip to first unread message

kartheektr...@gmail.com

unread,
Aug 18, 2015, 4:39:15 AM8/18/15
to Drools Usage
Hi,

I have written a rule below which will be triggered when it finds an email id in the text, but when I am executing this getting the below error which is due to the method call matcher.end().
Drools is finding it as end keyword and throwing the exception

Please suggest me on rectifying this

: Error while creating KieBase[Message [id=1, level=ERROR, path=../../../emailaddress.drl, line=22, column=0
   text=[ERR 107] Line 22:95 mismatched input '(' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.], Message [id=2, level=ERROR, path=../../../emailaddress.drl, line=0, column=0
   text=Parser returned a null Package]]

RULE:

rule "emailaddress rules"

 dialect "java"
    when
          $emailAddress :String(this matches "^.*[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,}).*$")
    then
    System.out.println("Rule 1-Triggered");
    Pattern pattern=Pattern.compile("[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})");
    Matcher matcher=pattern.matcher($emailAddress);
    while(matcher.find()){
    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.");
    System.out.println("Email address is:"+$emailAddress.substring(matcher.start(),matcher.end()));

    }
        System.out.println("Rule Executed successfully");
end

Edson Tirelli

unread,
Aug 19, 2015, 11:38:25 AM8/19/15
to drools...@googlegroups.com
Thanks for reporting this. We will look into it. Meanwhile, can you
please open a JIRA ticket for it in order to track it?

Thank you,
Edson
> --
> You received this message because you are subscribed to the Google Groups
> "Drools Usage" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to drools-usage...@googlegroups.com.
> To post to this group, send email to drools...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/drools-usage/9131d308-109f-4a09-90b3-68be44649f9b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Edson Tirelli
Principal Software Engineer
Red Hat Business Systems and Intelligence Group

Mario Fusco

unread,
Aug 20, 2015, 3:15:25 AM8/20/15
to Drools Usage
Hi,

I reported this issue here https://issues.jboss.org/browse/DROOLS-889 and fixed it on master with this commit https://github.com/droolsjbpm/drools/commit/49fdcf94b

As a temporary workaround for your problem I suggest you to put the code snippet invoking that end() method in another static java method and calling this second one from the rule's consequence.

Cheers,
Mario

Reply all
Reply to author
Forward
0 new messages