Still can't understand why I'm getting a cast exception when I call an object method when the object has been returned in a Collection from an EJB.
The object CountryModel is a serialised object, returned in a Collection from home.findAllCountries.....
I understood RMI returns the object in serialised form, why does called the CountryModel object method getCountryName() cause a ClassCast method? This object casting works ok for a non-rmi application.
Collection boris = home.findAllCountries();
Iterator i = boris.iterator();
System.out.println( boris.size()); //gets right results
while( i.hasNext()) {
Object obj = i.next();
CountryModel leModel = (CountryModel)obj;
System.out.println(leModel.getCountryName()); //causes ClassCastException
}
Any help appreciated. Thanks, lebo