Проблема с сериализацией

Рейтинг: 1Ответов: 1Опубликовано: 15.05.2011

Здравствуйте. При работе с сериализацией столкнулся с проблемой: создал массив байт из обьекта, послал как аргумент в метод, в методе пытаюсь восстановить объект - выдает ошибку. Причем оказалось что посланый массив не совпадает с полученым... Не могу понять, в чем дело. Вот код:

Передача:

byte[] bytes = null;
try {
    ByteArrayOutputStream fos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(new Cell(1,"test","test","test"));
    //oos.flush();
    oos.close();
    bytes = fos.toByteArray();
    System.out.println(bytes.toString());
    remoteComponent.func(bytes);
} catch (FileNotFoundException ex) {
    Logger.getLogger(Consol.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
    Logger.getLogger(Consol.class.getName()).log(Level.SEVERE, null, ex);
}

Получение:

try {
    System.out.println(bytes.toString());            
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    ObjectInputStream oin = new ObjectInputStream(in);
    Cell ts = (Cell) oin.readObject();
} catch (IOException ex) {
    Logger.getLogger(MyRemoteComponent.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
    Logger.getLogger(MyRemoteComponent.class.getName()).log(Level.SEVERE, null, ex);
}

Ошибка:

java.lang.ClassNotFoundException: rmiclient.Cell

Ответы

Ответов пока нет.