• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Problem with serialization via shutdown hook thread

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I'm having a particularly perplexing problem. I have an application that uses a custom subclass of a JTree to hold some data. I want this data to persist after the user closes the application, so my idea was to have the application serialize the Tree when it exits, and deserialize it when it starts again.
Initially I accomplished this using the "windowClosing()" method, and it worked fine, but then I realized that on some platforms (Mac OS X, for instance), the "WindowClosing()" event is not necessarily fired when the user quits the application.
So, I switched to having the serialization done in a shutdown hook thread. Now, whenever the application shuts down, it reaches the point where it starts the serialization, but then simply hangs!
Any ideas what might cause this? Two things that might be of note:
1. I started testing to make sure that my Tree isn't null before I try to serialize it (my theory being that maybe the object was being disposed before I tried to serialize it)--and it isn't.
2. If I try to serialize a new instance of the Tree class rather than my existing one, everything works fine--the class serializes and the application exits normally.
Thanks in advance,
Buzz Andersen
[ May 13, 2002: Message edited by: Buzz Andersen ]
 
Buzz Andersen
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More info: when I run the program on Mac OS X, it doesn't hang, but rather crashes with the following message:
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTreeUI.paintRow(BasicTreeUI.java:1309)
at javax.swing.plaf.basic.BasicTreeUI.paint(BasicTreeUI.java:1120)
at com.apple.mrj.swing.MacTreeUI.paint(MacTreeUI.java:137)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:39)
at javax.swing.JComponent.paintComponent(JComponent.java:395)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JComponent.paintChildren(JComponent.java:498)
at javax.swing.JComponent.paint(JComponent.java:700)
at javax.swing.JViewport.paint(JViewport.java:710)
at javax.swing.JComponent._paintImmediately(JComponent.java:3836)
at javax.swing.JComponent.paintImmediately(JComponent.java:3676)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:455)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
Don't know if that helps...
Buzz
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic