• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassCastException after RemoteCall

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic