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

Posted on 2007-10-08
Last Modified: 2012-06-27
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, but several Linux users have reported the same problem.

The end of my log file looks like this:
  <message>redrawing boardlayer

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
Question by:olbion2

    Accepted Solution

    Have you tried putting debugging info in your logs to trace the root cause of the problem?
    LVL 26

    Assisted Solution

    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'
    LVL 5

    Assisted Solution

    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!
    LVL 5

    Expert Comment

    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.
    LVL 5

    Expert Comment

    Did any of the ideas above work for you?  

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d… provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
    Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now