islandguy10
asked on
Urgent-Errors with Serialization
This is a school assignment so I just want some direction. I really need some help with serialization. I've read all the java sources and looked at many examples and I feel like I've been doing everything properly but whatever I try it seems that I still get a java.io.NotSerializableExc eption. Could someone point out where I am going wrong here? My two important classes are attached. Thanks!
TestLibGUI.java
Library.java
TestLibGUI.java
Library.java
you didn't post Book class, make sure it is Serializable
ASKER
Ok, I attached it. Books is Serializable, as are these other two classes Title, and Borrower. I have some exception classes as well which all implement Serializable as well.
Book.java
Title.java
Borrower.java
Book.java
Title.java
Borrower.java
NotSerializableException is usually constructed with the name of the offending class as the message. What value is returned when you call toString() on the exception?
ASKER
This is what I see in the NetBeans display. But, I'm not sure exactly where or what is causing the exception.
java.io.NotSerializableExc eption: TestLibGUI$6
at java.io.ObjectOutputStream .writeObje ct0(Object OutputStre am.java:11 56)
at java.io.ObjectOutputStream .defaultWr iteFields( ObjectOutp utStream.j ava:1509)
at java.io.ObjectOutputStream .writeSeri alData(Obj ectOutputS tream.java :1474)
at java.io.ObjectOutputStream .writeOrdi naryObject (ObjectOut putStream. java:1392)
at java.io.ObjectOutputStream .writeObje ct0(Object OutputStre am.java:11 50)
at java.io.ObjectOutputStream .writeObje ct(ObjectO utputStrea m.java:326 )
at java.util.HashMap.writeObj ect(HashMa p.java:100 1)
at sun.reflect.NativeMethodAc cessorImpl .invoke0(N ative Method)
at sun.reflect.NativeMethodAc cessorImpl .invoke(Na tiveMethod AccessorIm pl.java:39 )
at sun.reflect.DelegatingMeth odAccessor Impl.invok e(Delegati ngMethodAc cessorImpl .java:25)
java.io.NotSerializableExc
at java.io.ObjectOutputStream
at java.io.ObjectOutputStream
at java.io.ObjectOutputStream
at java.io.ObjectOutputStream
at java.io.ObjectOutputStream
at java.io.ObjectOutputStream
at java.util.HashMap.writeObj
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"TestLibGUI$6" means "the sixth anonymous nested class in TestLibGUI. I'll bet it's choking on your various ActionListeners and MouseListeners.
After refreshing this question, I see objects has pointed out the likely culprit. Try taking out the empty braces after the Book constructor.
After refreshing this question, I see objects has pointed out the likely culprit. Try taking out the empty braces after the Book constructor.
ASKER
That was it! Thanks a lot!...I'm new to this site still and I think I missed the part where I can split the points. :/ Your comments were very helpful as well CPColin. My head feels a lot better now!!!!!