M
Mario Rosario
Hi,
I am getting an error and 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 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
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 {
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...
}
---------------------------------------------------------------------
I am getting an error and 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 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
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 {
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...
}
---------------------------------------------------------------------