Hi to All,

I am new to Drools 5.0...
I created three classes(Student, College and StudentCollege) and Decistion table(manohar.xls) like this:-
Student.java:

package com.model;

public class Student {
        private int age;
        private int marks;
        public  String department;
       
        public int getAge() {
                return age;
        }
        public void setAge(int age) {
                this.age = age;
        }
        public int getMarks() {
                return marks;
        }
        public void setMarks(int marks) {
                this.marks = marks;
        }
        public String getDepartment() {
                return department;
        }
        public void setDepartment(String department) {
                this.department = department;
        }
       

}



College.java:

package com.model;

public class College {
        private String ranking;
        private String location;
        public String status;
       
       
        public String getLocation() {
                return location;
        }
        public void setLocation(String location) {
                this.location = location;
        }
        public String getStatus() {
                return status;
        }
        public void setStatus(String status) {
                this.status = status;
        }
        public void setRanking(String ranking) {
                this.ranking = ranking;
        }
        public String getRanking() {
                return ranking;
        }
       
       
        }
       

StudentCollege.java:

package com.model;
import java.io.IOException;

import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.DecisionTableConfiguration;
import org.drools.builder.DecisionTableInputType;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.compiler.DecisionTableFactory;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;

public class Student_College {
       
        public static void main(String args[])
        {
               
                Student s=new Student();
                College c=new College();
                s.setAge(18);
                s.setMarks(85);
                c.setRanking("A");
                c.setLocation("Delhi");
               
               
               
                try
                {
                        KnowledgeBase kbase = readBase();
                        StatefulKnowledgeSession ksession  = kbase.newStatefulKnowledgeSession();
                       
                        ksession.insert(s);
                        ksession.insert(c);
                        ksession.fireAllRules();
                        System.out.println("Department is "+s.getDepartment());
                       
                        System.out.println("Status is " + c.getStatus());
                         
                        ksession.dispose();
                       
                       
                       
                }
                catch(Exception e)
                {
                        System.out.println("Error is "+e);
                       
                }
               
        }
       
        private static KnowledgeBase readBase()
        {
                DecisionTableConfiguration dconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
                dconf.setInputType(DecisionTableInputType.XLS);
               
                KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
                kbuilder.add(ResourceFactory.newClassPathResource("manohar.xls", Student_College.class), ResourceType.DTABLE, dconf);
               
                //Printing the rules in detail
                String drlString = null;
                try {
                        drlString = DecisionTableFactory.loadFromInputStream(ResourceFactory.newClassPathResource("com/model/manohar.xls").getInputStream(), dconf);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                 
                  System.out.println("..........."+drlString);
               
                 
               
               
                if(kbuilder.hasErrors())
                {
                        throw new RuntimeException(kbuilder.getErrors().toString());
                       
                }
               
                KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
                kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
                 
                return kbase;
               
               
        }

}



manohar.xls:

RuleSet com.model
Import com.model.Student, com.model.College
RuleTable for gettingthe Department and Status of the College
CONDITION CONDITION CONDITION CONDITION ACTION ACTION
$s:Student $s:Student $c:College $c:College
age== marks== ranking== location== $s.setDepartment($param); $c.setStatus($param);
18
85
A Delhi Science AICTE
18
90
B Kanpur Science AICTE
20
90
A Mumbai Maths AICTE
23
87
C Hyderabad Physics AICTE



I am getting following errors while executing the StudentCollege.java, Please help me in getting output...


Error is java.lang.RuntimeException: Duplicate declaration for variable '$s' in the rule 'for  gettingthe Department and Status of the College_10' : [Rule name='for  gettingthe Department and Status of the College_10']
Duplicate declaration for variable '$c' in the rule 'for  gettingthe Department and Status of the College_10' : [Rule name='for  gettingthe Department and Status of the College_10']
Duplicate declaration for variable '$s' in the rule 'for  gettingthe Department and Status of the College_11' : [Rule name='for  gettingthe Department and Status of the College_11']
Duplicate declaration for variable '$c' in the rule 'for  gettingthe Department and Status of the College_11' : [Rule name='for  gettingthe Department and Status of the College_11']
Duplicate declaration for variable '$s' in the rule 'for  gettingthe Department and Status of the College_12' : [Rule name='for  gettingthe Department and Status of the College_12']
Duplicate declaration for variable '$c' in the rule 'for  gettingthe Department and Status of the College_12' : [Rule name='for  gettingthe Department and Status of the College_12']
Duplicate declaration for variable '$s' in the rule 'for  gettingthe Department and Status of the College_13' : [Rule name='for  gettingthe Department and Status of the College_13']
Duplicate declaration for variable '$c' in the rule 'for  gettingthe Department and Status of the College_13' : [Rule name='for  gettingthe Department and Status of the College_13']
Rule Compilation error : [Rule name='for  gettingthe Department and Status of the College_10']
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_10_0.java (7:513) : Science cannot be resolved
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_10_0.java (8:538) : AICTE cannot be resolved
Rule Compilation error : [Rule name='for  gettingthe Department and Status of the College_12']
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_12_0.java (7:513) : Maths cannot be resolved
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_12_0.java (8:536) : AICTE cannot be resolved
Rule Compilation error : [Rule name='for  gettingthe Department and Status of the College_11']
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_11_0.java (7:513) : Science cannot be resolved
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_11_0.java (8:538) : AICTE cannot be resolved
Rule Compilation error : [Rule name='for  gettingthe Department and Status of the College_13']
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_13_0.java (7:513) : Physics cannot be resolved
        com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_13_0.java (8:538) : AICTE cannot be resolved






Thanks and Regards
Manohar Kokkula
Mailto: manohar.kokkula@tcs.com

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you