Wolfgang,<br><br>first of all let me reenforce one of the advices you already gave: never rely on overloading of functions. Always try to use different names for different functions. This will be even more true in Drools 6 especially if we will decide to take in the functional programming features I suggested a few months ago.<br>
<br>Said that, at the moment I am not sure where the problem could be. I fixed a few varargs related issues on mvel and I hoped it was ok now, but there is still the possibility that Bojan found an edge case.<br><br>Bojan, btw which version of Drools (and mvel) are you using? Of course I need to reproduce this issue to have a clue about what it is going wrong. I will try to do that on my own, but if you could send a self contained project reproducing this bug it could save me lots of time, make me sure that I am working on the "right" problem and allow me to focus on its resolution.<br>
<br>Cheers,<br>Mario<br><br><div class="gmail_quote">On Thu, Mar 7, 2013 at 4:42 PM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The problem is not the loop in isEqualMore. I think the problem is caused<br>
by MVEL not handling the signature (Ann...) correctly.<br>
<br>
@Mario: should MVEL be able to deal with such a function call?<br>
<br>
-W<br>
<br>
<br>
On 07/03/2013, Bojan Janisch <<a href="mailto:bojan.janisch@scai.fraunhofer.de">bojan.janisch@scai.fraunhofer.de</a>> wrote:<br>
> I've tested all 4 cases. It is strange that each Rule fired exactly one<br>
> time,<br>
> directly before the exception occurs. Here the rules, I've built them<br>
> exactly<br>
> for this problem.<br>
> ============================================<br>
> Test 1(isEqualMore):<br>
> rule "Test Experiment 1"<br>
> no-loop<br>
> when<br>
> $a1:ODMAnswer()<br>
><br>
> $a2:ODMAnswer(<br>
> !isEqual($a1,$a2),<br>
> comesAfter($a1,$a2,50))<br>
><br>
> $a3:ODMAnswer(<br>
> comesAfter($a2,$a3,20),<br>
> !isEqualMore($a1,$a2,$a3))<br>
> then<br>
> System.out.println("Test 1 works");<br>
> end<br>
><br>
> Result:<br>
> Same Runtime exception<br>
> ============================================<br>
> Test 2(isEqualThree):<br>
> rule "Test Experiment 2"<br>
> no-loop<br>
> when<br>
> $a1:ODMAnswer()<br>
><br>
> $a2:ODMAnswer(<br>
> !isEqual($a1,$a2),<br>
> comesAfter($a1,$a2,50))<br>
><br>
> $a3:ODMAnswer(<br>
> comesAfter($a2,$a3,20),<br>
> !isEqualThree($a1,$a2,$a3))<br>
> then<br>
> System.out.println("Test 2 works");<br>
> end<br>
> Result:<br>
> Works perfect without errors.<br>
> ============================================<br>
> Test 3(isEqualMore):<br>
> rule "Test Experiment 3"<br>
> no-loop<br>
> when<br>
> $a1:ODMAnswer()<br>
><br>
> $a2:ODMAnswer(<br>
> !isEqual($a1,$a2),<br>
> comesAfter($a1,$a2,5))<br>
><br>
> ($a3:ODMAnswer(<br>
> comesAfter($a2,$a3,5)) and<br>
> eval(!isEqualMore($a1,$a2,$a3)))<br>
> then<br>
> System.out.println("Test 3 works");<br>
> end<br>
> Result:<br>
> Works also without errors (I'm surprised).<br>
> ============================================<br>
> Test 4(isEqualThree):<br>
> rule "Test Experiment 4"<br>
> no-loop<br>
> when<br>
> $a1:ODMAnswer()<br>
><br>
> $a2:ODMAnswer(<br>
> !isEqual($a1,$a2),<br>
> comesAfter($a1,$a2,5))<br>
><br>
> ($a3:ODMAnswer(<br>
> comesAfter($a2,$a3,5)) and<br>
> eval(!isEqualThree($a1,$a2,$a3)))<br>
> then<br>
> System.out.println("Test 4 works");<br>
> end<br>
> Result:<br>
> Works perfect, but seems to get more matches<br>
> than the 3. experiment.<br>
> ============================================<br>
> Fazit:<br>
><br>
> In my eyes there seems to be a problem using a loop in a constraint.<br>
> Even if I use different names (see Test 2), I'm still getting the<br>
> runtime exception. As bonus test-case I've tried using Test 3 and<br>
> overloading the function, rather than using a different function name,<br>
> but this also failed.<br>
><br>
> Seems that I have to use eval() and different names if I want to compare<br>
> multiple named entities, though I still don't know why. Maybe the isEqual<br>
> call in the loop is calling itself and generating an out of bounds exception<br>
> at the last array entity.<br>
><br>
> Thank you wolfgang.<br>
><br>
> JB<br>
> ----- Ursprüngliche Mail -----<br>
> Von: "Wolfgang Laun" <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
> An: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
> Gesendet: Donnerstag, 7. März 2013 13:36:12<br>
> Betreff: Re: [rules-users] Cannot invoke method because<br>
> of ArrayIndexOutOfBoundsException<br>
><br>
> You have lost me - I'm not sure anymore what works and what doesn't.<br>
><br>
> Please check or rewrite, using the names<br>
> isEqualMore(Annotation... annos)<br>
> isEqualThree(Annotation a1, Annotation a2, Annotation a3)<br>
><br>
> 1) not $a5:ODMAnswer(..., ! isEqualX($a3,$a4,$a5) )<br>
> does not work for X==More and<br>
> does not work for X==Three<br>
><br>
> 2) not( $a5:ODMAnswer(...) and eval( ! isEqualX($a3,$a4,$a5) )<br>
> works for X==More and<br>
> works for X==Three<br>
><br>
> -W<br>
><br>
><br>
><br>
><br>
> On 07/03/2013, Bojan Janisch <<a href="mailto:bojan.janisch@scai.fraunhofer.de">bojan.janisch@scai.fraunhofer.de</a>> wrote:<br>
>>> Experiment 1<br>
>>> Please write isEqualThree for 3 Annotation arguments and use this,<br>
>>> just to make sure that these Problems are caused by Drools. (Do NOT<br>
>>> rely on overloading, use another name.)<br>
>><br>
>> I've created an isEqualThree function<br>
>><br>
>> public static boolean isEqualThree(Annotation a, Annotation b, Annotation<br>
>> c){<br>
>> if(isEqual(a,b) || isEqual(b,c) || isEqual(a,c)){<br>
>> return true;<br>
>> }<br>
>> return false;<br>
>> }<br>
>><br>
>> By the way, it works also with overloading, I've never had problems with<br>
>> overloading in Drools. And I've tested also with different names, the<br>
>> problem<br>
>> remains, even using different function names.<br>
>><br>
>>> Experiment 2<br>
>>> Using the isEqual as it is now, rewrite the last pattern as:<br>
>>><br>
>>> not ( $a5:ODMAnswer(<br>
>>> isInAnnotation($a1,$a5),<br>
>>> isBigger($a3,$a5) )<br>
>>> and<br>
>>> eval( ! isEqual($a3,$a4,$a5) )<br>
>>> )<br>
>><br>
>> Your condition works without problems using the isEqualThree function, it<br>
>> works<br>
>> also if I overload the function. It also works if I put the isEqual<br>
>> condition out<br>
>> of the eval, into the object constraints. But if I want to use my primary<br>
>> idea, using<br>
>> different names,<br>
>><br>
>> public static boolean isEqualMore(Annotation... a)<br>
>><br>
>> I still get the same error from the isEqualMore function.<br>
>><br>
>> java.lang.RuntimeException: cannot invoke method: isEqualMore<br>
>> at<br>
>> de.fraunhofer.scai.bio.uima.core.deploy.StatusCallbackListenerImpl.entityProcessComplete(StatusCallbackListenerImpl.java:151)<br>
>> at<br>
>> org.apache.uima.collection.impl.cpm.engine.CPMThreadGroup.notifyListener(CPMThreadGroup.java:103)<br>
>> at<br>
>> org.apache.uima.collection.impl.cpm.engine.CPMThreadGroup.uncaughtException(CPMThreadGroup.java:86)<br>
>> at java.lang.Thread.dispatchUncaughtException(Thread.java:1888)<br>
>> Caused by: java.lang.ArrayIndexOutOfBoundsException: 3<br>
>> at<br>
>> org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.executeAll(MethodAccessor.java:149)<br>
>> at<br>
>> org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:48)<br>
>> at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)<br>
>> at<br>
>> org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38)<br>
>> at org.mvel2.ast.Negation.getReducedValueAccelerated(Negation.java:48)<br>
>> at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)<br>
>> at<br>
>> org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:123)<br>
>> at<br>
>> org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:116)<br>
>> at org.mvel2.MVEL.executeExpression(MVEL.java:930)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:70)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConditionEvaluator.ensureBranchEvaluation(MvelConditionEvaluator.java:113)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:106)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConditionEvaluator.ensureCompleteEvaluation(MvelConditionEvaluator.java:90)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConditionEvaluator.getAnalyzedCondition(MvelConditionEvaluator.java:82)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:214)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConstraint.access$000(MvelConstraint.java:41)<br>
>> at<br>
>> org.drools.rule.constraint.MvelConstraint$1.run(MvelConstraint.java:201)<br>
>> at<br>
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)<br>
>> at<br>
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br>
>> at java.lang.Thread.run(Thread.java:679)<br>
>><br>
>> JB<br>
>><br>
>> ----- Ursprüngliche Mail -----<br>
>> Von: "Wolfgang Laun" <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
>> An: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
>> Gesendet: Donnerstag, 7. März 2013 06:46:29<br>
>> Betreff: Re: [rules-users] Cannot invoke method because<br>
>> of ArrayIndexOutOfBoundsException<br>
>><br>
>> On 06/03/2013, Bojan Janisch <<a href="mailto:bojan.janisch@scai.fraunhofer.de">bojan.janisch@scai.fraunhofer.de</a>> wrote:<br>
>>> But that's exactly what java is doing if you say the Arguments are<br>
>>> method(X... xs).<br>
>>> Java is then generating an array of the type you set and you can work<br>
>>> with<br>
>>> xs like an<br>
>>> normal array.<br>
>><br>
>> Yes, Java, but.<br>
>><br>
>>> By the way, seems I get this Error<br>
>>><br>
>>> Unable to Analyse Expression isEqual(new Annotation[]{$a3,$a4,$a5})<br>
>>> [Error: could not instantiate class]<br>
>>> [Near : {... isEqual(new Annotation[]{$a3,$a4,$a5}) ....}]<br>
>>> ^<br>
>>> [Line: 129, Column: 8]<br>
>><br>
>> Suspicious, may have to raise a JIRA.<br>
>><br>
>> Experiment 1<br>
>> Please write isEqualThree for 3 Annotation arguments and use this,<br>
>> just to make sure that these Problems are caused by Drools. (Do NOT<br>
>> rely on overloading, use another name.)<br>
>><br>
>> Experiment 2<br>
>> Using the isEqual as it is now, rewrite the last pattern as:<br>
>><br>
>> not ( $a5:ODMAnswer(<br>
>> isInAnnotation($a1,$a5),<br>
>> isBigger($a3,$a5) )<br>
>> and<br>
>> eval( ! isEqual($a3,$a4,$a5) )<br>
>> )<br>
>><br>
>><br>
>> -W<br>
>><br>
>>><br>
>>><br>
>>> The changed method is:<br>
>>><br>
>>> public static boolean isEqual(Annotation[] a){<br>
>>> ArrayList<Annotation> outLoop = new<br>
>>> ArrayList<Annotation>(Arrays.asList(a));<br>
>>> ArrayList<Annotation> inLoop = new<br>
>>> ArrayList<Annotation>(Arrays.asList(a));<br>
>>><br>
>>> for (Annotation anno1 : outLoop) {<br>
>>> inLoop.remove(anno1);<br>
>>> for (Annotation anno2 : inLoop) {<br>
>>> if(isEqual(anno1,anno2)){<br>
>>> return true;<br>
>>> }<br>
>>> }<br>
>>> }<br>
>>><br>
>>> return false;<br>
>>> }<br>
>>><br>
>>> ----- Ursprüngliche Mail -----<br>
>>> Von: "Wolfgang Laun" <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
>>> An: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
>>> Gesendet: Mittwoch, 6. März 2013 17:11:43<br>
>>> Betreff: Re: [rules-users] Cannot invoke method because<br>
>>> of ArrayIndexOutOfBoundsException<br>
>>><br>
>>> I wouldn't use (X... xs) in this context.<br>
>>><br>
>>> Try the simple modification of isEqual( Annotation[] annos ) and<br>
>>> call it with isEqual( new Annotation[]{$a3,$a4,$a5})<br>
>>> and we'll see what we'll see.<br>
>>><br>
>>> -W<br>
>>><br>
>>><br>
>>> On 06/03/2013, Bojan Janisch <<a href="mailto:bojan.janisch@scai.fraunhofer.de">bojan.janisch@scai.fraunhofer.de</a>> wrote:<br>
>>>> Like you wish wolfgang. The complete Rule is:<br>
>>>><br>
>>>> rule "Generate Finding_ConceptId"<br>
>>>> no-loop<br>
>>>> when<br>
>>>> $a1:ODMAnswer(<br>
>>>> q1:QuestionId,<br>
>>>> q1.toLowerCase.contains("diagnose") ||<br>
>>>> q1.toLowerCase.contains("indication"),<br>
>>>> q1.toLowerCase.contains("sections"),<br>
>>>> a1_begin:begin,<br>
>>>> label1:ResponseAttribute)<br>
>>>><br>
>>>> $a2:ODMAnswer(<br>
>>>> ResponseAttribute.contains(label1),<br>
>>>> QuestionId.contains("sectionheader"),<br>
>>>> comesBefore($a1,$a2));<br>
>>>><br>
>>>> $a3:ODMAnswer(<br>
>>>> q3:QuestionId,<br>
>>>> !q3.contains("finding.conceptId"),<br>
>>>> !q3.contains("itemGroup"),<br>
>>>> !q3.contains("section"),<br>
>>>> a3_begin:begin,<br>
>>>> a3_end:end,<br>
>>>> label2:ResponseAttribute,<br>
>>>> isInAnnotation($a1,$a3))<br>
>>>><br>
>>>> $a4:ODMAnswer(<br>
>>>> q4:QuestionId.contains("finding.conceptId"),<br>
>>>> a4_begin:begin,<br>
>>>> comesAfter($a2,$a4),<br>
>>>> isBetween($a2,$a3,$a4),<br>
>>>> isInAnnotation($a1,$a4))<br>
>>>><br>
>>>> not $a5:ODMAnswer(<br>
>>>> isInAnnotation($a1,$a5),<br>
>>>> isBigger($a3,$a5),<br>
>>>> !isEqual($a3,$a4,$a5))<br>
>>>> then<br>
>>>> String questionId = "finding.conceptId";<br>
>>>> String attribute = label1 +" "+ label2;<br>
>>>> int begin = a4_begin;<br>
>>>> int ende = a3_end;<br>
>>>> boolean addToIndexes = true;<br>
>>>><br>
>>>><br>
>>>> insert(annotate(aJCas, questionId, attribute, begin, ende,<br>
>>>> addToIndexes));<br>
>>>> end<br>
>>>><br>
>>>> The functions are in a seperate FactChecker class, because the<br>
>>>> "incode-comparison"<br>
>>>> was too much of a chaos. So I wrote functions which explains themselves<br>
>>>> what<br>
>>>> they do:<br>
>>>> ==================================================================<br>
>>>> public static boolean isInAnnotation(Annotation a, Annotation b){<br>
>>>> if(isNull(a,b)){<br>
>>>> return false;<br>
>>>> }<br>
>>>> if(b.getBegin() > a.getBegin() && b.getEnd() < a.getEnd()){<br>
>>>> return true;<br>
>>>> }<br>
>>>> if(a.getBegin() > b.getBegin() && a.getEnd() < b.getEnd()){<br>
>>>> return true;<br>
>>>> }<br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean isInAnnotation(Annotation... a){<br>
>>>> for (int i = 0; i < a.length; i++){<br>
>>>> if(i+1 == a.length){<br>
>>>> return false;<br>
>>>> }<br>
>>>> if(isInAnnotation(a[i], a[i+1])){<br>
>>>> return true;<br>
>>>> }<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean comesBefore(Annotation a, Annotation b){<br>
>>>> if(isNull(a,b)){<br>
>>>> return false;<br>
>>>> }<br>
>>>> if(b.getEnd() <= a.getBegin()){<br>
>>>> return true;<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean comesAfter(Annotation a, Annotation b){<br>
>>>> if(isNull(a,b)){<br>
>>>> return false;<br>
>>>> }<br>
>>>> if(a.getEnd() <= b.getBegin()){<br>
>>>> return true;<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean isEqual(Annotation a, Annotation b){<br>
>>>> if(isNull(a,b)){<br>
>>>> return false;<br>
>>>> }<br>
>>>> if(a.equals(b)){<br>
>>>> return true;<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean isEqual(Annotation... a){<br>
>>>> ArrayList<Annotation> outLoop = new<br>
>>>> ArrayList<Annotation>(Arrays.asList(a));<br>
>>>> ArrayList<Annotation> inLoop = new<br>
>>>> ArrayList<Annotation>(Arrays.asList(a));<br>
>>>><br>
>>>> for (Annotation anno1 : outLoop) {<br>
>>>> if(anno1 == null){<br>
>>>><br>
>>>> }<br>
>>>> inLoop.remove(anno1);<br>
>>>> for (Annotation anno2 : inLoop) {<br>
>>>> if(isEqual(anno1,anno2)){<br>
>>>> return true;<br>
>>>> }<br>
>>>> }<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean isNull(Annotation... a){<br>
>>>> for (Annotation annotation : a) {<br>
>>>> if(annotation == null){<br>
>>>> return true;<br>
>>>> }<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean isBigger(Annotation a, Annotation b){<br>
>>>> if(isNull(a,b)){<br>
>>>> return false;<br>
>>>> }<br>
>>>> if(a.getBegin() == b.getBegin() && a.getEnd() < b.getEnd()){<br>
>>>> return true;<br>
>>>> }<br>
>>>> if(b.getBegin() < a.getBegin() && a.getEnd() == b.getEnd()){<br>
>>>> return true;<br>
>>>> }<br>
>>>> if(b.getBegin() < a.getBegin() && a.getEnd() < b.getEnd()){<br>
>>>> return true;<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static boolean isBetween(Annotation a, Annotation b, Annotation<br>
>>>> c){<br>
>>>> if(isNull(a,b,c)){<br>
>>>> return false;<br>
>>>> }<br>
>>>> Annotation min = getMin(a,b);<br>
>>>> Annotation max = getMax(a,b);<br>
>>>><br>
>>>> if(isOverlapping(a,c) || isOverlapping(b,c)){<br>
>>>> return true;<br>
>>>> }<br>
>>>><br>
>>>> if(c.getBegin() > min.getEnd() && c.getEnd() < max.getBegin()){<br>
>>>> return true;<br>
>>>> }<br>
>>>><br>
>>>> return false;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static Annotation getMax(Annotation a, Annotation b){<br>
>>>> isNull(a,b);<br>
>>>> if(a.getBegin() >= b.getBegin()){<br>
>>>> return a;<br>
>>>> }<br>
>>>><br>
>>>> return b;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>> public static Annotation getMin(Annotation a, Annotation b){<br>
>>>> isNull(a,b);<br>
>>>> if(a.getEnd() <= b.getEnd()){<br>
>>>> return a;<br>
>>>> }<br>
>>>><br>
>>>> return b;<br>
>>>> }<br>
>>>> ==================================================================<br>
>>>><br>
>>>> I've posted all functions that are used by the rule. Actually it crushes<br>
>>>> if I use more than 2 statements in the isEqual() call in $a5.<br>
>>>> It works with !isEqual($a3,$a4) && !isEqual($a3,$a5) &&<br>
>>>> !isEqual($a4,$a5)<br>
>>>> but not with !isEqual($a3,$a4,$a5).<br>
>>>><br>
>>>> So do you got an idea where the problem comes from?<br>
>>>><br>
>>>> JB<br>
>>>><br>
>>>><br>
>>>> ----- Ursprüngliche Mail -----<br>
>>>> Von: "Wolfgang Laun" <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
>>>> An: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
>>>> Gesendet: Mittwoch, 6. März 2013 15:09:47<br>
>>>> Betreff: Re: [rules-users] Cannot invoke method because<br>
>>>> of ArrayIndexOutOfBoundsException<br>
>>>><br>
>>>> Nice try - but, please, don't. Kindly post the code that actually<br>
>>>> causes your problem.<br>
>>>><br>
>>>> -W<br>
>>>><br>
>>>><br>
>>>> On 06/03/2013, Bojan Janisch <<a href="mailto:bojan.janisch@scai.fraunhofer.de">bojan.janisch@scai.fraunhofer.de</a>> wrote:<br>
>>>>> Hello Guys,<br>
>>>>><br>
>>>>> sorry to bother you with this problem, but I'm out of ideas.<br>
>>>>> I'm using Drools in textmining-context and in basic I have<br>
>>>>> a function that checks 2 named entites for equality to<br>
>>>>> ensure that the entities are all different and that the rules<br>
>>>>> do work only on different named entity objects:<br>
>>>>><br>
>>>>> public static boolean isEqual(Annotation a, Annotation b){<br>
>>>>> if(a.equals(b)){<br>
>>>>> return true;<br>
>>>>> }<br>
>>>>><br>
>>>>> return false;<br>
>>>>> }<br>
>>>>><br>
>>>>> Sometimes there are conditions that need tests of more than<br>
>>>>> 2 named entites. For this I've written a super method that<br>
>>>>> calls the isEqual method in a loop:<br>
>>>>><br>
>>>>> public static boolean isEqual(Annotation... a){<br>
>>>>> ArrayList<Annotation> outLoop = new<br>
>>>>> ArrayList<Annotation>(Arrays.asList(a));<br>
>>>>> ArrayList<Annotation> inLoop = new<br>
>>>>> ArrayList<Annotation>(Arrays.asList(a));<br>
>>>>><br>
>>>>> for (Annotation anno1 : outLoop) {<br>
>>>>> inLoop.remove(anno1);<br>
>>>>> for (Annotation anno2 : inLoop) {<br>
>>>>> if(isEqual(anno1,anno2)){<br>
>>>>> return true;<br>
>>>>> }<br>
>>>>> }<br>
>>>>> }<br>
>>>>><br>
>>>>> return false;<br>
>>>>> }<br>
>>>>><br>
>>>>><br>
>>>>> My rules could (theoretically) now call the function<br>
>>>>> eval(isEqual($ne1,$ne2)) or<br>
>>>>> eval(isEqual($ne1,$ne2,$ne3) or even<br>
>>>>> eval(isEqual($ne1,$ne2,$ne3,$ne4,$ne5)) and so on.<br>
>>>>><br>
>>>>> So there starts my problem:<br>
>>>>><br>
>>>>> Each time I'm getting an ArrayIndexOutOfBounds Exception from the<br>
>>>>> second<br>
>>>>> method that looks like this:<br>
>>>>><br>
>>>>> java.lang.RuntimeException: cannot invoke method: isEqual<br>
>>>>> ...<br>
>>>>> at java.lang.Thread.dispatchUncaughtException(Thread.java:1888)<br>
>>>>> Caused by: java.lang.ArrayIndexOutOfBoundsException: 3<br>
>>>>> at<br>
>>>>> org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.executeAll(MethodAccessor.java:149)<br>
>>>>> at<br>
>>>>> org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:48)<br>
>>>>> at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108)<br>
>>>>> at<br>
>>>>> org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38)<br>
>>>>> ...<br>
>>>>><br>
>>>>> Could someone explain me what's wrong with my code? Thanks for any<br>
>>>>> help.<br>
>>>>><br>
>>>>> Greetings<br>
>>>>> JB<br>
>>>>> _______________________________________________<br>
>>>>> rules-users mailing list<br>
>>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>>><br>
>>>> _______________________________________________<br>
>>>> rules-users mailing list<br>
>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> rules-users mailing list<br>
>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>><br>
>>> _______________________________________________<br>
>>> rules-users mailing list<br>
>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>><br>
>>> _______________________________________________<br>
>>> rules-users mailing list<br>
>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>