0

Situation

Every once and a while my application seems to be freezing. The only indication of this that I get is that my browser will say "Waiting for localhost...". If I restart my browser and access my application it continues waiting. The only solution so far has been to turn off Tomcat then turn it back on. The problem then vanishes. I'm very confident this is a server side process that has taken over and nothing client-side.

Problem

Rather than only analyzing my code it would be nice to actually inspect what is Tomcat doing or working on at any given time, kind of like a "Tomcat Task manager". I suspect some process running in the background with the JVM is the culprit but I'm not sure how to go about analyzing that.

Questions

  1. What's the best way of looking at what the Tomcat is doing when no web requests are being made?

  2. Any idea what background process or threads I should look into as a possible culprit?

Possible Cause of Problem:

This problem started as soon as I started using a singleton across multiple pages. Before I commit to that as the cause I'd like to track down where the freezing is actually taking place.

Usman Mutawakil
  • 4,234
  • 7
  • 35
  • 74

1 Answers1

2

Here are 4 ways of diagnosing this which I've used in the past. Each one is a bit more complicated and you might or not be able to use it in your environment.

  1. Connect the application to VisualVM and see if the status of the threads (you might have a deadlock).

  2. Another similar alternative is to take a thread dump from the JVM, and you can see if you have several threads waiting for a lock). This page explains how to take a thread dump.

  3. Yet another option if you still cannot find it with those tools, you might need to use a profiler such as YourKit and see what your app is doing.

  4. And the last one is to run the application in remote debug mode and whenever your app stops to work properly, you can connect from your IDE to see exactly where it hangs.

Community
  • 1
  • 1
Augusto
  • 26,525
  • 5
  • 52
  • 82