• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Problem w/shutdown hook thread & serialization

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!
Does this sound like a deadlock problem, or does anyone else have any ideas on what might be causing the hang? 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.
Any ideas, or do you think I'm even in the right forum?
Thanks in advance,
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
One other thing: when I run the program on Mac OS X, it doesn't hang when shut down, but rather crashes with this message:
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...
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sounds to me you got a nullpointerexception
maybe when you add some code somone can point out the problem to you
Grow your own food... or this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic