cancel
Showing results for 
Search instead for 
Did you mean: 

References and ClassCastException

Former Member
0 Kudos

Hello,

Iu2019m getting the exception: java.lang.ClassCastException

If I have this:

List<Turno> turnos = (List<Turno>)this.servicioCrud.findAll(Turno.class);
    	String resp ="**--**"+turnos+"-----"+turnos.size();	
    	return resp;

It works and I have the next message:

class $Proxy18271 **--**[co.com.crystal.eficiencias.entidad.Turno @ c58068, co.com.crystal.eficiencias.entidad.Turno @ 713fba, co.com.crystal.eficiencias.entidad.Turno @ 10f0602, co.com.crystal.eficiencias.entidad.Turno @ 1537b2e]-----4

but if I try to print every item of the list, like this:

List<Turno> turnos = (List<Turno>)this.servicioCrud.findAll(Turno.class);
      String resp ="**--**"+turnos+"-----"+turnos.size();
      for (int i = 0; i < turnos.size(); i++) {
                  resp =  resp+" "+turnos.get(i).getDeTurno()+"\n";
            }
      
      return resp;

I get the exception:

Caused by: java.lang.ClassCastException: class co.com.crystal.eficiencias.entidad.Turno:crystal.com.co/servicio_crud_ear @com.sap.engine.boot.loader.ResourceMultiParentClassLoader@158b1a9@alive incompatible with class co.com.crystal.eficiencias.entidad.Turno:crystal.com.co/captura_produccion_ear @com.sap.engine.boot.loader.ResourceMultiParentClassLoader@1c589f@alive
at co.com.crystal.eficiencia.primera.CapturaPrimeraEjbBean.test(CapturaPrimeraEjbBean.java:409)
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:585)
at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:43)

I think the problem could be because de class Turno (which is in entidades.jar) are referenced in the two .ear files (servicio_crud.ear and captura_produccion_ear) through the tab u201CDependenciesu201D in the u201CComponent propertiesu201D.

I donu2019t know how I could reference the file entidades.jar without this problem.

Regards

Janeth

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Janeth,

It seems that entidades.jar (containing the class Turno) is being assembled in both of your apps (servicio_crud.ear and captura_produccion.ear) and that leads to the error.

You could try to only assemble it in servicio_crud.ear, and define a compile dependency on it in the respective module of captura_produccion.ear as well as a runtime dependency from captura_produccion.ear to servicio_crud.ear.

Or you could create a separate EAR DC to wrap entidades.jar and refer to it from both servicio_crud.ear and captura_produccion.ear (without assembling it into them).

HTH!

\-- Vladimir

Former Member
0 Kudos

Vladimir thank you so much!!!

Answers (0)