It's not a secret anymore!*
The moose likes Tomcat and the fly likes How to diagnose Tomcat hanging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to diagnose Tomcat hanging" Watch "How to diagnose Tomcat hanging" New topic
Author

How to diagnose Tomcat hanging

Robert Kenworth
Greenhorn

Joined: Feb 24, 2010
Posts: 3
Hello.

I am relatively new to Tomcat and servlets (about 6 months).

We recently deployed a Tomcat server to process payments and show customer information.
There is a good bit of backend processing when the user selects various controls on the screen.

Here is my problem.

After a minute or two Tomcat hangs. Not all the time. Its intermittent.

What can I do to diagnose this problem without putting in another build.
I want to look at the existing server as is and see whats happening.

Thanks for your help.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Ideally you should have QA and development environment where you could try to reproduce the production issues. The very first place to look is Tomcat and your application log files.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
What exactly do you mean by Tomcat "hanging"?

1. Completely stops accepting requests
2. All requests result in no response
3. Most requests continue to work but one or more just don't reply
4. something else

If this was my problem and the logs did not reveal the problem, I would use the Tomcat Management application to monitor the state of the server. It will show you what all the current requests are doing.

If heavy database interaction is involved you may be overloading the back end or failing to recover database connections. Does the servlet use a Database connection pool?

Bill
Robert Kenworth
Greenhorn

Joined: Feb 24, 2010
Posts: 3
What I mean by hanging.....

I select a control on the html screen to do something then the hourglass is displayed and nothing else happens. I expect a response page but never get it. I could wait for 5 or 10 minutes then eventually I close the browser. I'm not able to log back into the web site.

I'm only now learning how to use the manager console.

The site is useing connection pooling.

How would I use manager console to find where the problem is? What would I look for?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
That symptom sounds like the request has gone into an endless loop or is otherwise waiting for something that will never happen.

This will show on the Management list of request Threads as a Thread with a really long running time.

This happened to me once when I was experimenting with a servlet which accessed a javaspaces server to create a response - when I neglected to start the server, requests would wait for a connection - which of course never happened. Other requests were processed normally but eventually all Tomcat request threads were hung.

Does your application use a database connection pool?

Bill
Robert Kenworth
Greenhorn

Joined: Feb 24, 2010
Posts: 3
Problem solved.

Thanks for the info. Your suspicion about connection pooling was correct.

It took much work but I was able to duplicate the problem in my test environment.
It was just a matter of putting in debug statements all over the place to isolate the exact line of code causing the problem.


Tomcat configuration was set to allow no more than 10 db connections.
This was quickly being reached and the thread was stalling.
We increased the allowed connections for a temporary fix.

The permanent fix will be to rework the code to better manage the connections.

Thanks again.

 
wood burning stoves
 
subject: How to diagnose Tomcat hanging
 
Similar Threads
Rational Application Developer
Websphere server going down frequently. Please help.
Trouble restarting Tomcat 6.0.30 with Eclipse
Managing a jvm by using a shell
HttpSession management in Struts 2 using Jquery Ajax