Hello, I have a really weird problem on my hands. I hope this is the right forum to place it in.
Once every so often, the application we're writing just hangs all the sudden. No error messages, but responses are no longer being returned. However all it takes is a CTRL+C on the Tomcat console window, and everything works again!
After some testing, I found out that while in this state, some servlets and JSP pages return proper responses. More digging found that the difference between the hanging and none-hanging servlets and pages was the presence of System.out.println() calls. If the system is in this "hung" state, any servlet or JSP page that tries to write to the standard output just hangs. The rest return properly.
The following test JSP page compiles and runs properly:
as does the following:
but the following JSP page hangs upon execution, no output in either the browser or the Tomcat console:
Furthermore, if there is a syntax error in a JSP, an attempt to access it fails as well, with no response. I am assuming this is because the container tries to write the compile time exception/stacktrace to the standard error stream, and that causes the hang. Attempts to write to the standard out stream from a different application (deployed on the same server) hang as well.
Again, I have absolutely no clue what brings the system to this state, just that when this state is reached any attempts to do System.out.println() hang, and that CTRL+C on the console window exists the state.
I'm using Tomcat 5.0.30, running on Windows 2000 Pro.
Has anyone ever encountered anything like this? Does anyone have any suggestions?
Please close the resultset and statement in the jsp code u have given and check the result. This may make a difference for sure.
Regards Makarand Parab
Joined: Dec 13, 2004
Thank you for the reply! The JSP test page that uses the DB code does not hang, and the query works perfectly. My system is currently in this "hangs on System.out.println()" state, and I just refreshed this page a hundred times, and not once did it hang, so I have to assume that the DB code is not the problem. According to the J2SE javadocs, calling Connection.close() "Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released."
In the definition of the datasource being used in Tomcat's Server.xml, I also put
This should have automatically recycled any resources idle for 5 seconds, and thrown an exception afterwards alerting me to the leak. Obviously while the system is in the "writing to the standard out stream hangs" state I wouldn't see that error, but I've never seen it even when the system works perfectly.
The only thing I have detected that causes a hang in this state, is actually writing to the standard output or error streams. It's as if the console is frozen, so any attempt to write to it freezes as well, but everything else, including database access, works.
Thank you, Yuriy
Joined: Dec 13, 2004
All right, some progress here. On the advice of our System Administrator, I tried hitting CTRL+Q on the hung console (instead of CTRL+C as I've been doing.) This worked in "unhanging" the console. According to the sysadmin this means that somehow a "Stop" Signal was sent to the console, similar to hitting CTRL+S or Pause. Now what the heck could have done this? I guess this might be more of a Tomcat than a Servlet question at this point....