i am trying to create a mock shopping cart for a uni project. im using two java classes Item and shoppingCart, shopping cart uses a vector to store Items and then writes them to a file. i am trying to use the classes on a jsp page but when i try to write to the file i get an java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: cart.Item... any ideas how i could fix this??
+2
A:
From the javadoc on NotSerializableException... "Thrown when an instance is required to have a Serializable interface."
This means that your class that you're serializing need to implement the Serializable marker interface.
Yuliy
2009-05-05 07:04:44
You could add that it needs a 'serialVersionUID' in order to be Serializable.
boutta
2009-05-05 07:07:38
i have tried implementing Serializable on both classes with no luck
2009-05-05 07:08:11
Does Item contain any members that are not serializable? Otherwise, I'd double-check that you are indeed implementing java.io.Serializable.As for serialVersionUID, you should have that, but it won't result in NotSerializableException if you do not provide it (the runtime will auto-calculate the version ID when needed).
Yuliy
2009-05-05 16:21:14