I have this exception and I don\'t understand why it would be thrown or, how I should handle it.
try {
os.writeObject(element);
} catch (IOException e)
java.io.NotSerializableException can occur when you serialize an inner class instance because:
serializing such an inner class instance will result in serialization of its associated outer class instance as well
Serialization of inner classes (i.e., nested classes that are not static member classes), including local and anonymous classes, is strongly discouraged
Ref: The Serializable Interface