• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System.out.println() hanging?????

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

quick test:

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?

Thank you,
Yuriy
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Makarand,

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
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....

-Yuriy
[ August 09, 2005: Message edited by: Yuriy Zilbergleyt ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic