Search code examples
javadrools

Drools can not use a generic type for a function's parameter in DRL


I'm defining the next function on my DRL

function void embargarMultiplesCuentasJudicial(ArrayList<Cuenta> cuentas, Embargo embargo,BigDecimal montoTotal ,BigDecimal limite) {
    //BODY
}

And I'm getting this error:

Unable to resolve type ArrayList<Cuenta> while building function. java.lang.ClassNotFoundException: Unable to find class 'ArrayList<Cuenta>' ]]

But I'm importing the ArrayList and Cuenta at top's file

import modelo.Cuenta;
import modelo.Embargo;
import java.util.ArrayList;

Solution

  • Seems like you need to not mention what your ArrayList uses in the parameters. The following example works fine for me (it's an ArrayList of a custom Object) :

    function testFunction(ArrayList al)
    {
        System.err.println("Called a function with the ArrayList : " + java.util.Arrays.toString(al.toArray()));
    }