Hello,
In attachment there are a DRL file and java test case which causes the
NPE mentionned below.
Thanks,
Regards
Exception in thread "main" java.lang.NullPointerException
at
org
.drools
.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:948)
at
org
.drools
.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:727)
at
org
.drools
.rule.builder.PatternBuilder.createRestriction(PatternBuilder.java:504)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
351)
at
org
.drools
.rule.builder.PatternBuilder.buildConstraint(PatternBuilder.java:239)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
196)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
104)
at
org
.drools
.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:68)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:
649)
at
org
.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:
290)
at
org
.drools
.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at
org
.drools
.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at TestQuote.executeRule(TestQuote.java:37)
at TestQuote.main(TestQuote.java:19)
Le 3 sept. 09 à 22:06, PlugTree a écrit :
hmmm seems we met a bug here. post it to the list to see if anyone
knows something about it. If not I'll dig into the code to see the
problem.
Thanks!
CEO
plugtree.com
Joseph Berdat wrote:
> Hello,
>
> I've tried you proposition:
> $quote : Quote(value > (Double() from accumulate( Quote( $price :
> value ), average( $price ) ) ))
> Unfortunatly, it produces the following error:
> java.lang.NullPointerException
> at
> org
> .drools
> .rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:
> 948)
> at
> org
> .drools
> .rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:
> 727)
> at
> org
> .drools
> .rule.builder.PatternBuilder.createRestriction(PatternBuilder.java:
> 504)
> at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
> 351)
> at
> org
> .drools
> .rule.builder.PatternBuilder.buildConstraint(PatternBuilder.java:239)
> at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
> 196)
> at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:
> 104)
> at
> org
> .drools
> .rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
> at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:68)
> at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:
> 1159)
> at
> org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:
> 649)
> at
> org
> .drools
> .compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
> at
> org
> .drools
> .compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:
> 488)
> at
> org
> .drools
> .builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
> at
> home.prototype.business.service.QuoteTest.loadRule(QuoteTest.java:62)
> at home.prototype.business.service.QuoteTest.test1(QuoteTest.java:35)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun
> .reflect
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun
> .reflect
> .DelegatingMethodAccessorImpl
> .invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
> at
> org
> .junit
> .internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
> at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:
> 79)
> at
> org
> .junit
> .internal
> .runners
> .MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
> at
> org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
> at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
> at
> org
> .junit
> .internal
> .runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:
> 88)
> at
> org
> .junit
> .internal
> .runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
> at org.junit.internal.runners.JUnit4ClassRunner
> $1.run(JUnit4ClassRunner.java:44)
> at
> org
> .junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:
> 27)
> at
> org
> .junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> at
> org
> .junit
> .internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
> at
> org
> .eclipse
> .jdt
> .internal
> .junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> at
> org
> .eclipse
> .jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org
> .eclipse
> .jdt
> .internal
> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at
> org
> .eclipse
> .jdt
> .internal
> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at
> org
> .eclipse
> .jdt
> .internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
> 386)
> at
> org
> .eclipse
> .jdt
> .internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
> 196)
>
> Regards,
>
> Le 3 sept. 09 à 10:52, Plug Tree Labs a écrit :
>
>> Joseph:
>>
>> I think you should need something like this:
>>
>> $quote : Quote(value > (Double() from accumulate( Quote( $price :
>> value ), average( $price ) )))
>>
>> What do you think?
>>
>> joseph berdat wrote:
>>> Hello,
>>> The rule below check which quote have a price above the average.
>>> In this form the rule is working, but from the log files it seems
>>> that this rule is doing a cross join.
>>> rule "above average value"
>>> dialect "mvel"
>>> when
>>> Double( $average : doubleValue) from
>>> accumulate( Quote( $price : value ), average( $price ) )
>>> $quote : Quote(value > $average)
>>> then
>>> System.out.println("Quote above average [" + $quote.id + "]
>>> value [" + $quote.value + "] average [" + $average +
"]")
>>> end
>>> I could not get the correct syntax. I would like to write
>>> something like:
>>> when Quote(value > doubleValue) from accumulate( Quote( $price :
>>> value ), average( $price ) )
>>> Thanks,
>>> regards.
>>> ------------------------------------------------------------------------
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>