I am using Serialization at Server and De-serialization at android client as communication protocol.
The POJO used is defined as
@EntityTag(uri = "/t.do", layout_id = "teacher")
public class Teacher extends UIEntity{
private static final long serialVersionUID = (long)0x000010;
public Teacher() throws UIEntityFormatException {super();}
@ViewTag(view_id = "t_name")
private String name;
@ViewTag(view_id = "t_sur_name")
private String surName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurName() {
return surName;
}
public void setSurName(String surName) {
this.surName = surName;
}
}
The EntityTag and ViewTag are defined separately.
Code used to write Object in Server is
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
final Teacher t = new Teacher();
t.setName("jacob");
t.setSurName("bush");
final ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
oos.writeObject(t);
oos.flush();
} catch (UIEntityFormatException e) {
e.printStackTrace();
}
}
and Code used at client for receive this
final ObjectInputStream objectInputStream = new ObjectInputStream(response.getEntity().getContent());
ret = (Result) objectInputStream.readObject();
objectInputStream.close();
AndroidHttpClient is used. and an ClassNotFound for EntityTag.class is throw when client is run.
Teacher, UIEntity, and annotations are put in a Module called protocol and Client Server modules has dependency on that(I am using Intellij IDEA 13) I can not figure out what caused the Exception.
Thanks