[rules-users] JUnit testing

Marcus Ilgner marcus.ilgner at gmail.com
Mon May 19 06:02:47 EDT 2008


Hi list,

I'm reviving this thread because I happen to have the same problem.

On Sun, Mar 23, 2008 at 7:34 PM, Mike Dean <mdean77 at comcast.net> wrote:
>
> Thanks (months later!).  I have cut down my code example below to show this
> issue more clearly:
>
>
> John J. Franey wrote:
>>
>> NullPointerException on line 146 means classLoader is null.   That is odd.
>> I have no idea why the code that gets classLoader won't work in eclipse's
>> junit runtime, but does when run in your eclipse plugin.

 It seems indeed like during JUnit tests, the context classloader of
the thread gets not set (null).

The code leading up to the problem is as follows:
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
conf.getDialectConfiguration("java");
javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
javaConf.setJavaLanguageLevel("1.5");
RuleBase ruleBase = RuleBaseFactory.newRuleBase();

The resulting stacktrace is:
java.lang.NullPointerException
	at org.drools.RuleBaseConfiguration.instantiateClass(RuleBaseConfiguration.java:569)
	at org.drools.RuleBaseConfiguration.determineConsequenceExceptionHandler(RuleBaseConfiguration.java:561)
	at org.drools.RuleBaseConfiguration.init(RuleBaseConfiguration.java:220)
	at org.drools.RuleBaseConfiguration.<init>(RuleBaseConfiguration.java:133)
	at org.drools.common.AbstractRuleBase.<init>(AbstractRuleBase.java:147)
	at org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:124)
	at org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:101)
	at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:57)
	at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:38)

Has anyone set up Drools and JUnit successfully? Maybe we forgot to
set up the environment properly?

Best regards
Marcus



More information about the rules-users mailing list