• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic