开发者

AWT EventQueue NullPointerException

I have a signed applet which writes text files to a specified directory in a client workstation.

When I load the applet in a web browser for the first time, there was no problem. It manages to load in the browser and writes data to a text file. But when I continue to load it again, it just won't load. All I see is the Java loading image. Even after waiting for 10 minutes, the applet still won't load.

Unfortunately, this doesn't happen all the time. I've tried closing the web browser and clearing all its caches and temp files but sometimes it will occur again.

The client workstation has JRE 1.6.0_16 installed and it's running on Windows XP tested on IE8.

Below is the Applet tag code in the HTML page.

<applet code="com.applet.files.PrintTkt.class" archive="<%=BaseURL %>/UT/SPrintTkt.jar" width="500" height="450">
    <param NAME="ROOT" value="<%= BaseURL %>">
    <param NAME="CHARSET" value="<%= charset %>">
    <param NAME="batfile" value="<%= batfile %>">
    <param NAME="filename" value="<%= filename %>">
    <param NAME="PAGE_ID" value="PrintTkt">
</applet>

Below is the Stack Trace from the Java Console. The Exceptions below were thrown only when I refreshed the page, go to another page or logout from our web application. Prior to that, the stack trace only showed that the Applet is loading.

basic: Loading Java Applet ...
basic: Applet initialized
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@59a34
basic: Applet made visible
basic: Starting applet
basic: completed perf rollup
basic: Applet started
basic: Told clients applet is started
Exception in th开发者_运维问答read "AWT-EventQueue-6" java.lang.NullPointerException
    at java.awt.LightweightDispatcher$3.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(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)
Exception in thread "AWT-EventQueue-6" java.lang.NullPointerException
    at java.awt.LightweightDispatcher$3.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(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)
Exception in thread "AWT-EventQueue-6" java.lang.NullPointerException
    at java.awt.LightweightDispatcher$3.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(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)


I have encountered variants of this before. When a page containing an applet is reloaded it may reuse the classloader providing it has not been finalized. When this happens, classes that have already been loaded by that classloader are not reloaded. This can cause some nasty issues with static members. The class is already loaded, so the class-statics do not get reinitialized. And, you wind up with a class static that is not null, but the value it holds is no longer valid.

Check your code for static members and eliminate where possible. If you can't eliminate them, add hooks to the applet stop method to set the static values to null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜