Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to diagnose Tomcat hanging

 
Robert Kenworth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic