The moose likes EJB and Other Java EE Technologies and the fly likes ClassCastException after RemoteCall Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and Other Java EE Technologies
Reply Bookmark "ClassCastException after RemoteCall" Watch "ClassCastException after RemoteCall" New topic
Author

ClassCastException after RemoteCall

koshka Sagar
Greenhorn

Joined: Nov 15, 2001
Posts: 2
I get a ClassCastException after remote call.
The business method takes a parameter and returns a Vector containing objects of a class. after the remote call when i print the size of the vector and use the getClass().getName() on the object retrieved from the vector it gives me the name of the class correctly. but if i try to typecast this class to the X class it give me a ClassCastException.
Summary :
1. The object returned after the remote call is a vector that
contains X class objects. X class implements Serializable
interface.
2. using the narrow() of PortableRemoteObject
3. Remote call is successful with no Remote Exceptions. Vector
that is returned after remote call has size greater than Zero.
4. Iterating thru the vector to retreive X class object and
casting it gives exception.
Code :
Context ctx = NameLookup.getInitialContext();
Object objref = ctx.lookup(JNDI_NAME);
HighlighterSessionHome home = (HighlighterSessionHome)
PortableRemoteObject.narrow(objref,HighlighterSessionHome.class);
HighlighterSession highlighterEJB = home.create();
//vector of X class objects
Vector highlights = highlighterdEJB.getHighlights(employeeId);
for(int i = 0;i<highlights.size();i++)>
{
//GIVES CLASS CAST EXCEPTION HERE---
X high = (X)highlights.elementAt(i);
System.out.println("high.preText : " + high.preText);
}

* X class implements Serializable interface.
Main feature :
This code works fine on weblogic6.0 but is failing on websphere 4.0
 
IntelliJ Java IDE
 
subject: ClassCastException after RemoteCall
 
Threads others viewed
clientID
Unserializable error
Vector reading... Plz help :)
programming to the interface
developer file tools