Michael,
Can you show us your rule(s) please? it is raising the NPE when trying to
get the list of variables you use in the consequence... as soon as we
determine what the real problem is, I can fix the error message...
[]s
Edson
2007/10/30, Michael Fuller <mfuller(a)ihets.org>:
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(
JavaConsequenceBuilder.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.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.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
_______________________________________________
rules-users mailing list
rules-users(a)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