Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

serializing Handle to java.lang.String  RSS feed

 
Nitzan Levi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i'm trying to serialize the handle igot from a ejb to a string an then deserialize it and work with him.
i did the serializing with the folowing code :
public String serializeService(EJBObject service) {
String res;
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(bytes);
oo.writeObject(service.getHandle());
//res = bytes.toString();
res = new String(bytes.toByteArray());
System.out.println(res);
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
public EJBObject deserializeService(String serializedService) {
EJBObject res;
try {
ObjectInputStream oi = new ObjectInputStream(new ByteArrayInputStream(serializedService.getBytes()));
Handle hand = (Handle) oi.readObject();
res = hand.getEJBObject();
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
the proble accur whan i'm trying to deserialize the handle , i'm getting ...Local Class Not Compatible , the serializing and the deserializing both accur on the same servlet
do you have any ideas ??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!