[rules-users] RuntimeException "cannot invoke method" ArrayIndexOutOfBoundsException in Drools expert 5.5

aleste moisesventura at gmail.com
Thu Jun 6 08:04:40 EDT 2013


I've found a problem (probably a bug in mvel) running drools expert 5.5. 

The MessageSourceElement constructor uses variable arguments:
           public MessageSourceElement(Enum<?> enumerationElement, Object...
parameters) {

My drl contains a method with consequence:

  then
 	insert (new
MessageSourceElement(ValidationException.MESSAGE_LIST.USER_CANT_OVERRIDE_THEMSELVES,
new Object[]{}))
  end

If I manually create the array of objects and pass it to the constructor it
works correctly, but if I try to use variable parameters:

insert (new
MessageSourceElement(ValidationException.MESSAGE_LIST.USER_CANT_OVERRIDE_THEMSELVES))

insert (new
MessageSourceElement(ValidationException.MESSAGE_LIST.USER_CANT_OVERRIDE_THEMSELVES,
something, somethingElse))

I experince a very strange behavior: The first time the rule executes
properly, but any subsequent execution fails with RuntimeException "cannot
invoke method" ArrayIndexOutOfBoundsException 1

This happens because the second time mvel tries to call the two parameters
constructor (Enum, Object[]) no matter what the real constructor we are
trying to use (Enum), (Enum, SomeObject, SomeAnotherObject) and fails when
trying to extract the parameters by reflection.

I don't know if this is a known bug or if it should be reported, I hope it
will save some time someone.





--
View this message in context: http://drools.46999.n3.nabble.com/RuntimeException-cannot-invoke-method-ArrayIndexOutOfBoundsException-in-Drools-expert-5-5-tp4024170.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list