[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

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.NotSerializableException.  Could someone point out where I am going wrong here?  My two important classes are attached.  Thanks!
TestLibGUI.java
Library.java
0
islandguy10
Asked:
islandguy10
  • 3
  • 2
  • 2
1 Solution
 
objectsCommented:
you didn't post Book class, make sure it is Serializable
0
 
islandguy10Author Commented:
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
0
 
CPColinSenior Java ArchitectCommented:
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?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
islandguy10Author Commented:
This is what I see in the NetBeans display.  But, I'm not sure exactly where or what is causing the exception.

java.io.NotSerializableException: TestLibGUI$6
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
        at java.util.HashMap.writeObject(HashMap.java:1001)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
0
 
objectsCommented:
>                     Library.getLibrary().addBook(new Book(title, amtBooks, remBooks) {});

you're using an inner class for creating Books. THat won't work, you need to create a (non-inner) Book subclass
0
 
CPColinSenior Java ArchitectCommented:
"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.
0
 
islandguy10Author Commented:
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!!!!!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now