Skip to Content
0
Former Member
Jul 21, 2008 at 09:22 PM

References and ClassCastException

27 Views

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