Hi
     I wrote code for creating RuleBase. But I got error at retrieving URL
resource by passing ruleFile to the getResource() method.It is returning
null. How to get the URL resource. I posted the sample code which  i have
written for creating RuleBase.
public RuleBase createRuleBase() throws Exception
{
                if(rules==null)
                {
                        throw new Exception("No rules provided for Engine");
                }
                
                ruleBase = RuleBaseFactory.newRuleBase();
                PackageBuilder builder = new PackageBuilder();          
                
                for(String ruleFile : rules)
                {
                        System.out.println("Rule is "+ruleFile); //prints
the ruleFile
                        URL resource = this.getClass().getResource(ruleFile); 
//gets the URL
resource of the ruleFile
                        
                        if(resource==null)
                        {
                                System.err.println("Could not find resource: 
"+ruleFile);
                                continue;
                        }

                        File file = new 
File(this.getClass().getResource(ruleFile).getPath());
                        if(!file.exists())
                        {
                                System.err.println("Could not find rule file: 
"+file.getPath());
                                continue;
                        }
                        
                        builder.addPackageFromDrl(new 
FileReader(file.getPath()));
                }
                
                org.drools.rule.Package pkg = builder.getPackage();             
                ruleBase.addPackage(pkg);       
                
                return ruleBase;
        }

My Packages are not adding to RuleBase.It is returning null.

How to add the packages to ruleBase.Please suggest me

Thanks

--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-add-Packages-to-RuleBase-tp3653477p3653477.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to