Bad problem! :(

Hello everyone, maybe someone knows how to solve this or where the problem is? Tnx!

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at org.jdesktop.layout.GroupLayout$ComponentSpring.installIfNecessary(GroupLayout.java:2216)

at org.jdesktop.layout.GroupLayout.registerComponents(GroupLayout.java:864)

at org.jdesktop.layout.GroupLayout.registerComponents(GroupLayout.java:866)

at org.jdesktop.layout.GroupLayout.registerComponents(GroupLayout.java:866)

at org.jdesktop.layout.GroupLayout.registerComponents(GroupLayout.java:866)

at org.jdesktop.layout.GroupLayout.registerComponents(GroupLayout.java:866)

at org.jdesktop.layout.GroupLayout.prepare(GroupLayout.java:815)

at org.jdesktop.layout.GroupLayout.layoutContainer(GroupLayout.java:671)

at java.awt.Container.layout(Container.java:1432)

at java.awt.Container.doLayout(Container.java:1421)

at java.awt.Container.validateTree(Container.java:1519)

at java.awt.Container.validateTree(Container.java:1526)

at java.awt.Container.validateTree(Container.java:1526)

at java.awt.Container.validateTree(Container.java:1526)

at java.awt.Container.validateTree(Container.java:1526)

at java.awt.Container.validateTree(Container.java:1526)

at java.awt.Container.validate(Container.java:1491)

at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:635)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

[2203 byte] By [kode128a] at [2007-11-27 3:00:11]
# 1

Hi Kode128 $

Sun already provided a Solution for this bug.

See bellow.

Bug ID: 5088782

Synopsis AWT application does not load : throws NPE

Category java:classes_awt

Reported Against 1.4.2_05

Release Fixed 1.5.0_01

State Closed, fixed

Related Bugs

Submit Date 18-AUG-2004

Description AWT application which adds lot of awt components to a panel,

which inturn is added to a Frame, throws an exception when

the number of components increases.

For simulating the problem, see the comments part.

1.4.2_04,1.4.2_05 gives the following exception :

Exception in thread "main" java.lang.NullPointerException: disposed component

at sun.awt.windows.Win32SurfaceData.initOps(Native Method)

at sun.awt.windows.Win32SurfaceData.<init>(Unknown Source)

at sun.awt.windows.Win32SurfaceData.createData(Unknown Source)

at sun.awt.windows.WComponentPeer.<init>(Unknown Source)

at sun.awt.windows.WLabelPeer.<init>(Unknown Source)

at sun.awt.windows.WToolkit.createLabel(Unknown Source)

at java.awt.Label.addNotify(Unknown Source)

at java.awt.Container.addNotify(Unknown Source)

at java.awt.Panel.addNotify(Unknown Source)

at java.awt.Container.addNotify(Unknown Source)

at java.awt.Panel.addNotify(Unknown Source)

at java.awt.Container.addNotify(Unknown Source)

at java.awt.Window.addNotify(Unknown Source)

at java.awt.Frame.addNotify(Unknown Source)

at java.awt.Window.pack(Unknown Source)

at Grid.main(Grid.java:27)

1.5.2-beta2 :

the application hangs with the following stack trace:

-Stack Trace Begins here

Full thread dump Java HotSpot(TM) Client VM (1.5.0-beta2-b51 mixed mode, sharing

):

"AWT-EventQueue-0" prio=7 tid=0x009fd5e0 nid=0x7b8 waiting for monitor entry [0x

0398f000..0x0398fbe4]

at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)

- waiting to lock <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)

at sun.awt.windows.WComponentPeer$2.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

"AWT-Shutdown" prio=7 tid=0x009f9e20 nid=0xcc in Object.wait() [0x0388f000..0x03

88fc64]

at java.lang.Object.wait(Native Method)

at java.lang.Object.wait(Unknown Source)

at sun.awt.AWTAutoShutdown.run(Unknown Source)

- locked <0x22facef8> (a java.lang.Object)

at java.lang.Thread.run(Unknown Source)

"AWT-Windows" daemon prio=7 tid=0x009fa1e8 nid=0x7bc runnable [0x0376f000..0x037

6fce4]

at sun.awt.windows.WToolkit.eventLoop(Native Method)

at sun.awt.windows.WToolkit.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x009f8d38 nid=0x678 in Object.wait() [0x03

56f000..0x0356f9e4]

at java.lang.Object.wait(Native Method)

- waiting on <0x22facf80> (a java.lang.ref.ReferenceQueue$Lock)

at java.lang.ref.ReferenceQueue.remove(Unknown Source)

- locked <0x22facf80> (a java.lang.ref.ReferenceQueue$Lock)

at java.lang.ref.ReferenceQueue.remove(Unknown Source)

at sun.java2d.Disposer.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

"Low Memory Detector" daemon prio=5 tid=0x0099bd38 nid=0x330 runnable [0x0000000

0..0x00000000]

"CompilerThread0" daemon prio=10 tid=0x0099a850 nid=0x714 waiting on condition [

0x00000000..0x0303f8bc]

"Signal Dispatcher" daemon prio=10 tid=0x00999b10 nid=0x128 waiting on condition

[0x00000000..0x00000000]

"Finalizer" daemon prio=9 tid=0x0023eea8 nid=0x600 in Object.wait() [0x02e3f000.

.0x02e3fc64]

at java.lang.Object.wait(Native Method)

- waiting on <0x22fad128> (a java.lang.ref.ReferenceQueue$Lock)

at java.lang.ref.ReferenceQueue.remove(Unknown Source)

- locked <0x22fad128> (a java.lang.ref.ReferenceQueue$Lock)

at java.lang.ref.ReferenceQueue.remove(Unknown Source)

at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x009979a0 nid=0x44c in Object.wait() [0x

02d3f000..0x02d3fce4]

at java.lang.Object.wait(Native Method)

at java.lang.Object.wait(Unknown Source)

at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)

- locked <0x22fad1a8> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x00236030 nid=0x63c runnable [0x0006f000..0x0006fc3c]

at sun.awt.windows.WPanelPeer.pRestack(Native Method)

at sun.awt.windows.WPanelPeer.restack(Unknown Source)

at java.awt.Component.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Container.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Panel.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Container.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Panel.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Container.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Window.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Frame.addNotify(Unknown Source)

- locked <0x22fb1a48> (a java.awt.Component$AWTTreeLock)

at java.awt.Window.show(Unknown Source)

at java.awt.Component.show(Unknown Source)

at java.awt.Component.setVisible(Unknown Source)

at Grid.main(Grid.java:24)

"VM Thread" prio=10 tid=0x00976100 nid=0x628 runnable

"VM Periodic Task Thread" prio=10 tid=0x0099d2c0 nid=0x6f0 waiting on condition

--Stack Trace Ends

Justification: Customer has migrated their product to use Sun JVM from Microsoft JVM.

With their new release, end users of the customer are unable to see the application. This accounts to a total failure of a feature they used to support with Microsoft JVM.

Work Around Possible workaround can be: don't use so many heavyweight components. If you really do need such amount of components you should use lightweights (for example, Swing)

xxxxx@xxxxx 2004-08-19

Evaluation The problem is trivial out of memory error. When we create a window object for a heavyweight component we just store its handle in hwnd field but don't check it is 0. In the test we create many window handles so at some moment system refuses creating more window objects.

We should check return value of CreateWindow() and if it is 0 throw OutOfMemoryError (if GetLastError() corresponds to out of memory) or InternalError (otherwise).

xxxxx@xxxxx 2004-08-19

spidersurfa at 2007-7-12 3:41:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...