class cast problem on value object with a Collection
i have a value object with a Collection of custom class in it.
public class MyValueObject implements Serializable{
int i;
String name;
Collection variables;
}
the variables collection holds the following class
public class MyVariable implements Serializable{
String name;
String type;
String value;
}
when i pass the value object from EJB to the client, everything works fine. so i try to let the client modify the value object and pass it back to EJB.
in MyValueObject class i have the following code to read the value of the variables.
Iterator it = variables.iterator();
while (it.hasNext()){
Object obj = it.next();
MyVariable variable = (MyVariable)obj;
}
when this code is executed on the server side i receive a ClassCastException.
my question is why the same piece of code works when the value object is passed from server to client while it does not work when the value object is passed from client to server?
i am using jbuilder with BAS 4.5. when i step into the code, i can actually see through my debugger that obj is indeed a MyVariable instance. but i don't know why i can not cast. i can read other values of the Value Object all right. all class files are kept in one jar file.
Thanks.
jack.

