• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 814
  • Last Modified:

Java applet hangs randomly in Linux; how can I identify the cause?

I have a java applet which mostly runs fine. However, when used in Linux, it sometimes hangs. The exact behaviour is this:
1. After repeating the same exact action in the applet for a number of times, the applet stops responding.
2. The browser (Firefox) still works; however, to be able to use java plugins again, Firefox must be restarted AND the java_vm process must be manually killed.
3. No errors are reported in the log files. Tracing, logging and "applet lifecycle expectations" are all enabled.
4. The java_vm takes up a lot of cpu when it hangs, so I guess that it gets stuck in a loop.

My questions:

How can I identify the problem?

Is there some way to log the activities of java in more detail so as to understand at what point the error occurs?

Is there perhaps some known "bug" - that is, some piece of java code which causes applets to hang under Linux?

I myself run Ubuntu Feisty with Java 1.5.0.11, but several Linux users have reported the same problem.

The end of my log file looks like this:
<record>
  <date>2007-10-08T19:32:16</date>
  <millis>1191864736982</millis>
  <sequence>199</sequence>
  <logger>sun.plugin</logger>
  <level>FINE</level>
  <class>com.sun.deploy.util.LoggerTraceListener</class>
  <method>print</method>
  <thread>10</thread>
  <message>redrawing boardlayer
</message>
</record>

The end of the trace file says (repeated about 15 times in all):
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
redrawing boardlayer
0
olbion2
Asked:
olbion2
  • 3
3 Solutions
 
Phil_CrusaderCommented:
Have you tried putting debugging info in your logs to trace the root cause of the problem?
0
 
ksivananthCommented:
try printing the dump on the applet console, which will give the details of currently executing code and its state!

to print the dump, open the console, press 'l'
0
 
ebertkCommented:
Ok - here is what I have done in these situations.  First make sure that the java console is enabled for Firefox (which it probably is) - then put in a bunch of System.out.println()'s to create your own output to the console when the applet is running.  

When the applet is running and its stuck in a loop somewhere you won't get any output to the log or console unless you create some yourself.  As far as the JVM is concerned its working just like it was programmed (even if there is an error).

Here's an example:

for (int i=0; i<100; i--) {
  // Do some work
  x = x +1;
// output a line to the system console
  System.out.println(" inside i loop, current value is " + i );
}

If you do something like the above you will get a series of system out's in the console and you can narrow down where your error is, in my experience once you find where it is, its pretty easy to get the answer or ask another more specific question.

Also note  - my example above creates a nice infinite loop!
0
 
ebertkCommented:
One more comment - start out with a small numerb of System.out's that cover the entire section of the applet that appears to be a problem.  Then create additional system.out's in your code to narrow down where the error is occuring.  You may find its either your code or part of a call to the JVM, but an iterative approach will zero in on the issue.
0
 
ebertkCommented:
Did any of the ideas above work for you?  
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now