Hi
I have have a file with some rules. When I load the rules as a drl-file all my junit-tests
work. But when I load the rules as PKG one of the rule is failing.
This is the rule causing the problem
rule "Lookup synonym" when $normalization : NormalizationFact(valid,
resultFact == null) NormalizerMetadataService(synonymNames contains
$normalization.type ) $synonymService : SynonymService() then
System.out.println(drools.getRule().getName()); modify($normalization) {
setResultFact(new ResultFact($synonymService.getValue($normalization.getType(),
$normalization.getValue()))) }end
After some investigation I can reduce the problem to
setResultFact(new ResultFact("")) <-------------------------
WorkingsetResultFact(new ResultFact(null)) <------------------------- Not working, see
log below
This is the code executed in ResultFact
public class ResultFact { private final String result; private final boolean valid;
public ResultFact(String result) { this(result, true); }
public ResultFact(String result, Boolean valid) { super(); this.result =
result; this.valid = valid; }
other methods ...}
The exception I get is
Exception executing consequence for rule "Lookup synonym" in normalization:
[Error: $normalization.setResultFact(new ResultFact(null)): array index out of
bounds.][Near : {... $normalization.setResultFact(n ....}] ^[Line: 1, Column:
1] at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297) at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221) at
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456) at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710) at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674) at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230) at
com.mawell.normalize.service.rule.DroolsRuleEvaluatorImpl.evaluate(DroolsRuleEvaluatorImpl.java:62) at
com.mawell.normalize.service.infrastructure.util.backend.SynonymServiceTest.execute(SynonymServiceTest.java:126) at
com.mawell.normalize.service.infrastructure.util.backend.SynonymServiceTest.execute(SynonymServiceTest.java:115) at
com.mawell.normalize.service.infrastructure.util.backend.SynonymServiceTest.ShouldNotTranslate_q(SynonymServiceTest.java:75) 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:597) at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at
org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at
org.junit.runners.ParentRunner.run(ParentRunner.java:236) at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused
by: [Error: $normalization.setResultFact(new ResultFact(null)): array index out of
bounds.][Near : {... $normalization.setResultFact(n ....}] ^[Line: 1, Column:
1] at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:424) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:143) at
org.mvel2.ast.ASTNode.optimize(ASTNode.java:159) at
org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115) at
org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42) at
org.mvel2.ast.WithNode$ParmValuePair.eval(WithNode.java:278) at
org.mvel2.ast.WithNode.getReducedValueAccelerated(WithNode.java:67) at
org.mvel2.ast.InterceptorWrapper.getReducedValueAccelerated(InterceptorWrapper.java:40) at
org.mvel2.MVELRuntime.execute(MVELRuntime.java:85) at
org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119) at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113) at
org.mvel2.MVEL.executeExpression(MVEL.java:930) at
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:104) at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287) ... 32 moreCaused
by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at
java.lang.String.substring(String.java:1931) at
java.lang.String.substring(String.java:1904) at
org.mvel2.util.ErrorUtil.rewriteIfNeeded(ErrorUtil.java:12) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:959) at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:377) ...
46 more
I'm running version 5.5.0.Final of both Drools and Guvnor.
regardsMarkus
Show replies by date