[rules-users] Unexpected Token Exception
Edson Tirelli
tirelli at post.com
Thu May 31 18:01:37 EDT 2007
Rajesh,
If you are using 4.0 MR2, it should work. In 3.0.x is not possible to
nest multiple patterns inside an EXISTS and NOT CEs.
Although, the following is an example of the rule that works both in
3.0.x and 4.0.
rule XXX
when
$student : Student()
exists Module( student == $student, score < 40 )
then
// add $student to the list of students that failed a module
end
Hope it helps,
Edson
2007/5/31, Rajesh.Sachin10 <rajesh_sachin10 at yahoo.co.in>:
>
>
> I got the following exception when I tried to run the drl file rule.
>
> org.drools.rule.InvalidRulePackage: unknown:13:37 mismatched token:
> [@79,307:308='&&',<55>,13:37]; expecting type ')'
> unknown:13:81 Unexpected token ')'
>
> at org.drools.rule.Package.checkValidity(Unknown Source)
> at org.drools.common.AbstractRuleBase.addPackage(Unknown Source)
> at com.sample.DroolsTest.main(DroolsTest.java:47)
>
>
> Rule:
>
> package com.policy;
> #expander Ex1.dsl;
> #list any import classes here.
> #import java.util.HashMap;
> import java.util.Iterator;
> import com.examples.Student;
> import com.examples.Module;
> #declare any global variables here
> global java.util.List errorlist;
>
> rule "Ex1"
> when
> exists( $student : Student() && Module( student == $student, score
> <
> 40 ))
> then
> System.out.println("fierd");
> end
>
>
> Files:
> Class 1:
>
> package com.examples;
>
>
> public class Student {
> private String name;
> private Object[] modules;
> public Object[] getModules() {
> return modules;
> }
> public void setModules(Object[] modules) {
> this.modules = modules;
> }
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
>
> }
>
>
>
>
> class 2:
>
> package com.examples;
>
> public class Module {
> private String name;
> private String studentName;
> private int score;
>
> public Module(String name, int score){
> this.setName(name);
> this.setScore(score);
> }
>
>
> public String getName() {
> return name;
> }
> public void setName(String name) {
>
> this.name = name;
> }
> public int getScore() {
> return score;
> }
> public void setScore(int score) {
> this.score = score;
> }
> public String getStudentName() {
> return studentName;
> }
> public void setStudentName(String studentName) {
> this.studentName = studentName;
> }
> }
>
>
> Anyone have any idea about it
>
>
> --
> View this message in context:
> http://www.nabble.com/Unexpected-Token-Exception-tf3848843.html#a10901896
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070531/5521e838/attachment.html
More information about the rules-users
mailing list