Hi all,

I have some set of rules which work on same Person object but depending on
whether a person is student/employee/Faculty, the rule will have dfferent
logic.

So, I've made 3 .drl files, one will have all the rules for students, other
for employee and then last .drl for faculty. All 3 .drl have same package
name (as the first statement in drl) but all rules are named differently.
When my rule engine starts, it reads these 3 drl files and adds them to a
single rule base, starts a new session, inserts person in working memory and
fires rules.

Now, my questions are...is there anything odd/wrong with this approach?
Secondly, I had some rules names same in different drl and when I changed
them ....then I started getting null pointer exception error..... during
parsing of drl files. Any idea why is that?

code snippet:

list=new ArrayList<File>();
list.add(new File("students.drl"));
list.add(new File("emloyee.drl");
list.add(new File("faculty.drl"));

Iterator<File> it = list.iterator();
ruleBase = RuleBaseFactory.newRuleBase();
builder = new PackageBuilder();
Reader source=null;
        while(it.hasNext())
        {
        source =  new
InputStreamReader(RuleEngine.class.getResourceAsStream(it.next().toString()));
        builder.addPackageFromDrl(source);
                //if DRL has errors don't add it to the RuleBase
                if(builder.hasErrors())
                log4j.logError(RuleEngine.class, 
builder.getErrors().toString());
                else
                ruleBase.addPackage(builder.getPackage());
             }
workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(person);
workingMemory.fireAllRules();
-- 
View this message in context: 
http://www.nabble.com/DRL-package-builder-or-rule-base-error-tp20627083p20627083.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to