I have the following code: (note String[] ruleFiles contains only one
string)
public class Engine {
private static RuleBase ruleBase;
public void start(String[] ruleFiles) throws Exception {
PackageBuilderConfiguration cfg = new
PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
cfg.getDialectConfiguration("java");
javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
PackageBuilder builder = new PackageBuilder(cfg);
for (String file : ruleFiles) {
builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file)));
}
Package pkg = builder.getPackage();
PackageBuilderErrors errors = builder.getErrors();
if (errors.getErrors().length != 0) {
// do something
}
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setAssertBehaviour(RuleBaseConfiguration.AssertBehaviour.EQUALITY);
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
ruleBase.newStatefulSession(false);
}
}
At the builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file))); line
I'm getting the following exception:
java.lang.NullPointerException
at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaCo
nsequenceBuilder.java:54)
at
org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
at
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
:167)
at
myPackage.rivoli.service.rules.Engine.start(Engine.java:33)
at
myPackage.rivoli.rules.LeaderKingAndHeirTest.setUp(LeaderKingAndHeirTest
.java:26)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
I am using Drools 4.0.3
I have the following jars in my class path:
antlr-runtime-3.0.jar
core-3.2.3.v_686_R32x.jar
drools-compiler-4.0.3.jar
drools-core-4.0.3.jar
mvel14-1.2.10.jar
Any ideas would be helpful. Thanks.
Michael Fuller
"In theory there is no difference between theory and practice. But, in
practice, there is." - Jan L.A. van de Snepscheut