Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By kjkrum

Thread: Java Swing app seriliazation problem

  1. #1
    heatblazer is offline Senior Member
    Join Date
    Nov 2012
    Posts
    137
    Rep Power
    0

    Question Java Swing app seriliazation problem

    Hello. I am trying to save a state of a big GUI Swing app. I am trying to save the containers (ArrayLists and JPanels too ). But I am recieving an exceptions:
    Java Code:
    ilian.Quiz.MainApp$5
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)
    	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
    	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
    	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
    	at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1377)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1173)
    	at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:162)
    	at java.io.ObjectOutputStream$PutFieldImpl.writeFields(ObjectOutputStream.java:1706)
    	at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:481)
    	at java.awt.Container.writeObject(Container.java:3681)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
    	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
    	at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1377)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1173)
    	at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:162)
    	at java.io.ObjectOutputStream$PutFieldImpl.writeFields(ObjectOutputStream.java:1706)
    	at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:481)
    	at java.awt.Container.writeObject(Container.java:3681)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
    	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
    	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
    	at java.util.ArrayList.writeObject(ArrayList.java:742)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
    	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
    	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
    	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
    	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
    	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
    	at com.ilian.Quiz.QSerialize.serialize(QSerialize.java:10)
    	at com.ilian.Quiz.QADList.updateForward(QADList.java:143)
    	at com.ilian.Quiz.MainApp$5.actionPerformed(MainApp.java:241)
    	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    	at java.awt.Component.processMouseEvent(Component.java:6505)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    	at java.awt.Component.processEvent(Component.java:6270)
    	at java.awt.Container.processEvent(Container.java:2229)
    	at java.awt.Component.dispatchEventImpl(Component.java:4861)
    	at java.awt.Container.dispatchEventImpl(Container.java:2287)
    	at java.awt.Component.dispatchEvent(Component.java:4687)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    	at java.awt.Container.dispatchEventImpl(Container.java:2273)
    	at java.awt.Window.dispatchEventImpl(Window.java:2719)
    	at java.awt.Component.dispatchEvent(Component.java:4687)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    	at java.awt.EventQueue.access$200(EventQueue.java:103)
    	at java.awt.EventQueue$3.run(EventQueue.java:694)
    	at java.awt.EventQueue$3.run(EventQueue.java:692)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    	at java.awt.EventQueue$4.run(EventQueue.java:708)
    	at java.awt.EventQueue$4.run(EventQueue.java:706)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    Can you tell me what is causing it? I guess anonymous classes like new Thread(new Runnable(...) will cause errors. Any info?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java Swing app seriliazation problem

    Quote Originally Posted by heatblazer View Post
    Hello. I am trying to save a state of a big GUI Swing app. I am trying to save the containers (ArrayLists and JPanels too ). But I am recieving an exceptions:
    Java Code:
    ilian.Quiz.MainApp$5
    Can you tell me what is causing it?
    Who knows? You chopped off the real start of the error message.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    heatblazer is offline Senior Member
    Join Date
    Nov 2012
    Posts
    137
    Rep Power
    0

    Default Re: Java Swing app seriliazation problem

    That`s the start - the catch block printStackTrace()

  4. #4
    heatblazer is offline Senior Member
    Join Date
    Nov 2012
    Posts
    137
    Rep Power
    0

    Default Re: Java Swing app seriliazation problem

    The exception thrown is java.io.NotSerializableException sorry, I`ve forgot to add it.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Java Swing app seriliazation problem

    When I get an exception, the first thing I wonder is: under which circumstances do you get that exception? The answer is usually very simply found by copy/pasting the exception (java.io.NotSerializableException in this case) into Google; I would try that with this one as an exercise to see how easy it is to get the answer.

    And the answer in this case is: somewhere in the object hierarchy that you're trying to serialize, there is an object with a class that does not implement serializable. The follow up question then becomes: how do I deal with that? Perhaps you need to make something serializable, perhaps you need to in fact NOT serialize some specific object but make it transient.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Java Swing app seriliazation problem

    A more important question is why are you trying to do this? Serializing the UI itself suggests that you've violated the MVC pattern in a big way. It's almost inconceivable that you would actually want to serialize your view instead of your model.
    JosAH likes this.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Problem with java.swing.JFrame
    By Filoflow in forum New To Java
    Replies: 8
    Last Post: 03-13-2013, 05:05 PM
  2. Problem using Threads and Swing in Java
    By Walter in forum New To Java
    Replies: 3
    Last Post: 11-26-2011, 12:10 AM
  3. Facing problem in Java Swing
    By hbeon in forum AWT / Swing
    Replies: 2
    Last Post: 12-07-2010, 01:11 AM
  4. Java Swing Problem
    By mohitgupta1989 in forum Advanced Java
    Replies: 7
    Last Post: 06-23-2010, 08:46 AM
  5. Java Swing GridBagLayout Problem
    By hemanthjava in forum AWT / Swing
    Replies: 1
    Last Post: 06-29-2008, 09:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •