This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Tomcat hanging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat hanging" Watch "Tomcat hanging" New topic

Tomcat hanging

Roel De Nijs

Joined: Jul 19, 2004
Posts: 8412

On a webserver i have following situation:
- 2 instances of Tomcat 5.0.28 installed in 2 different maps (TomcatA en TomcatB under C:\Program Files\Apache Software Foundation)
- the latest JDK version: jdk1.5.0 update 4
- Each Tomcat instance starts up with following extra parameters: -Xms1568m -Xmx1568m

Starting them up causes no problems, but after some time (it's not on a regular base) TomcatA is hanging and you can't do anything more in the web-application. The only thing you can do is stop tomcat and restart it

The web-app writes a line at the beginning of an action and at the end of an action to a log-file with log4j. So the line at the beginning of the action is written to the log-file, but that's all. I also write the MBs of free memory to the log, i calculate it with the following code

And on the moments that Tomcat is hanging there is plenty of free Memory, so a outofmemory exception can't be the cause. There is also no error thrown, so i am completely out of possibilities and any help is appreciated !

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
What exactly do you mean by hanging: does it not generate responses anymore? Does it eat up lots of CPU time? Does the process exit? Are there any exceptions in the Tomcat logs (not your application logs)?
And since you know from the logfile the action in which it's hanging: what is happening in that action?
Roel De Nijs

Joined: Jul 19, 2004
Posts: 8412

Ok, here i am again. Sorry it took so long before i get back, but today the tomcat was hanging again and i have the answers on your questions:

- no errors are written in any log (so not in my application log, not in the tomcat log, nor in the tomcat console window): no errors at all
- the cpu time of the server is 0%, so it's not eating up all cpu, but you don't get any response
- today i did some brainstorm because it happens in several cases and all these cases have something in common: they go to a database to get some information. so there is something wrong (95% sure about this one)

we use jTDS to go to our ms sql server and we use version 0.9. I downloaded the latest version and will try this one and see what the results are with that one.

when you just restart tomcat the problem is solved and i wonder why it takes about approx a month to get this strange behaviour and it happens each day.

any tips, hints or suggestions are more than welcome
thanks anyway
Roel De Nijs

Joined: Jul 19, 2004
Posts: 8412


After pointing the problem to the database and database access, i added some debug messages printing out the number of active connections and the maximum of active connections. and after some time the number of active connections equals the maximum, so no connection to the database can be established and tomcat seems hanging.

Cause of the problem: some connections to the database were not closed like it's supposed to be
I agree. Here's the link:
subject: Tomcat hanging
It's not a secret anymore!