:scrambleup: Estou criando um Session Bean Stateful.
Ao tentar reconectar ao bean usando um id obtido do service locator obtenho a exceção:
java.io.InvalidClassException: org.jboss.util.id.UID; local class incompatible: stream classdesc serialVersionUID = 4588799618105892224, local class serialVersionUID = -8093336932569424512
/*** Método utilizado para reconectar ao EJB **/
public EJBObject getService(String id)
throws ServiceLocatorException {
if (id == null) {
throw new ServiceLocatorException("NULL");
}
try {
System.out.println(id);
byte[] bytes = id.getBytes();
InputStream io = new ByteArrayInputStream(bytes);
ObjectInputStream os = new ObjectInputStream(io);
Object o = os.readObject();
javax.ejb.Handle handle = (javax.ejb.Handle) o;
return handle.getEJBObject();
} catch(Exception ex) {
ex.printStackTrace();
throw new ServiceLocatorException("Location Fail");
}
}
/*** Método utilizado para obter o Id do EJB **/
public String getId(EJBObject session)
throws ServiceLocatorException {
try {
javax.ejb.Handle handle = session.getHandle();
ByteArrayOutputStream fo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(fo);
so.writeObject(handle);
so.flush();
so.close();
return new String(fo.toByteArray());
} catch(RemoteException ex) {
throw new ServiceLocatorException("Falha na Comunicação");
} catch(IOException ex) {
throw new ServiceLocatorException("Falha na Leitura");
}
}
Uso:
J2sdk1.4.2
JBoss 4