Search code examples
grailsgroovybonita

Groovy Cannot cast object RowLitigeLivraison@e0bc67a with class RowLitigeLivraison to RowLitigeLivraison


I tried to resolve this problem with groovy script. I had the exception:

Groovy script throws an exception of type class org.codehaus.groovy.runtime.typehandling.GroovyCastException with message: Cannot cast object 'org.bonitasoft.mbricolage.mrbricolibrary.objects.RowLitigeLivraison@3daae7cd' with class 'org.bonitasoft.mbricolage.mrbricolibrary.objects.RowLitigeLivraison' to class 'org.bonitasoft.mbricolage.mrbricolibrary.objects.RowLitigeLivraison'

When i try to execute this code :

Dossier dossier1 = dossierDAO.findByNumero(dossier.getNumero());
        ArrayList<LigneLitige> lignes = new ArrayList<LigneLitige>();
        if (formResultObj.getContext().getChoix() == "1"){

            for (RowLitigeLivraison ligneDeLitige : formResultObj.getLitigeLivraison().getList()){
                if (ligneDeLitige.getReserves() > 0){
                    LigneLitige litige = new LigneLitige();
                    litige.setCodeAmpf(ligneDeLitige.getAmpf());
                    litige.setGenCode(ligneDeLitige.getGencode());
    }}}

Where formResultObj.getLitigeLivraison().getList() returns a RowLitigeLivraison list.


Solution

  • That could happen sometimes if you get two version of the Jar that contains this class. By example, if you have it deployed in the application web and as a dependency of the process.

    Is that the case here?

    Cheers