Monthly Archives: January 2011

java.io.NotSerializableException – but where is the field?

To enable more informations about "java.io.NotSerializableException" just add the "-Dsun.io.serialization.extendedDebugInfo=true" VM argument to your run configuration. Example: java -Dsun.io.serialization.extendedDebugInfo=true -jar your.jar Without extendedDebugInfo:
Exception in thread "main" java.io.NotSerializableException: net.nautsch.addressbook.Country
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
        at net.nautsch.addressbook.App.main(App.java:33)
and with:
Exception in thread "main" java.io.NotSerializableException: net.nautsch.addressbook.Country
        - field (class "net.nautsch.addressbook.Address", name: "country", type: "class net.nautsch.addressbook.Country")
        - object (class "net.nautsch.addressbook.Address", net.nautsch.addressbook.Address@13caecd)
        - field (class "net.nautsch.addressbook.Person", name: "address", type: "class net.nautsch.addressbook.Address")
        - root object (class "net.nautsch.addressbook.Person", net.nautsch.addressbook.Person@158b649)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1161)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
        at net.nautsch.addressbook.App.main(App.java:33)