tags:

views:

122

answers:

1

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 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)
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)
A: 

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.

Devon_C_Miller
sorry for the late reply. I've tried many things together and it seems I do not see it occur again. Unfortunately, our codes do not have static methods as you mentioned.Below are the things I did:a) added attributes "id", "name" and also "classloader_cache" with the value set to "false".b) this applets connects to a servlet. In the servlet, I've removed global variables.c) Each time I closed the browser, then only I saw NullPointerExceptions thrown in the log file. I've changed the codes to deal with the NullPointerException
Alvin Sim