By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Expert Help - class invalid for deserialization.

P: n/a
Hi,

I am getting an error which I don't understand why.

I have an object Item which I serialize within a servlet and send it across
to an applet but I get this run time error "java.io.InvalidClassException:
com.webacre.servlet.Item; class invalid for deserialization". I tried
changing all compile target to 1.1 but it didn't help. Does anyone know what
The code seem right to me. I am doing wrong? What do I need to do to make
this work?

Thanks for your help.
Mario

---------------Applet.java---(compile target Java 1.1)------------
import com.webacre.servlet.Item;
... <stuff deleted> ...

v = new Vector();
ObjectInputStream in = new ObjectInputStream(con.getInputStream());
while ((item = (Item)in.readObject()) != null) {
v.addElement(item);
}
-------------------------------------------------------------------
---------------Servlet.java----(compile target Java 1.4)-----------
import com.webacre.servlet.Item;
... <stuff deleted> ...

ObjectOutputStream out = new ObjectOutputStream(res.getOutputStream());
for (int i=0; i < list.size(); i++) {
out.writeObject((Item)list.get(i));
}
-------------------------------------------------------------------

----------- Item.java -----(compile target Java 1.4)----------------
package com.webacre.servlet;
import java.io.Serializable;

public class Item implements Serializable {

static final long serialVersionUID = 99999999999999L;

private int id = -1;
private double width = 0.0;
private String catalog = "-";

public int getItemId() { return this.id; }
public void setItemId(int i) { this.id = i; }
...etc...
}
---------------------------------------------------------------------


Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.