Portlet Factory, Version 6.1.2


 

Class cast exceptions when accessing objects in a collection of entity beans

Refer to this when a class cast exception is encountered.

If a class cast exception such as this:

com.bowstreet.util.WrappedException: java.lang.ClassCastException: org.omg.stub.javax.ejb._EJBObject_Stub at genjava._dd.Employee_getAttributeValue(_dd.java:322) at java.lang.reflect.Method.invoke(Native Method)

is encountered when accessing the beans in a returned collection (if a "findAll" type method has been executed), an EntityBean remote interface was expected, but a generic object stub was returned.

It is likely that the objects in the returned collection need to be narrowed to the correct type. For example, if the EJB call set up an employees variable for the collection being returned, you could convert the objects in that collection as follows:

{ java.util.Collection c =
(java.util.Collection)webAppAccess.getVariables().getObject("employees"); java.util.Iterator iter = c.iterator(); java.util.Collection c2 = new java.util.Vector(); while (iter.hasNext()) Object o = iter.next(); o = javax.rmi.PortableRemoteObject.narrow(o, com.bowstreet.ejb.Employee.class); c2.add(o); webAppAccess.getVariables().setObject("employees", c2);
}

Note: You would substitute your variable for employees and the class name you expect for com.bowstreet.ejb.Employee in the example.

Parent topic: EJB Call builder


Library | Support |