May 9th, 2012, 08:04 AM
Application hangs for no apparent reason
I'm new to Spring so forgive me if this is a completely ignorant question.
I've been developing a blog application to practice using Spring and Hibernate. I've noticed that as a click around my application, after about 8 - 10 link clicks, my application will hang. I don't get any errors, no exceptions pop up in my debugger and there doesn't appear to be anything telling in my Spring log files. I've tried to step through my code as well and there doesn't seem to be any point in my code that my IDE chokes on. The application will just sit there trying to load the next page forever.
Are there any other logs/places I can check to see what's going on besides what I already tried? I'm using Tomcat as my web container. To be honest, I'm not even sure if this a Spring problem, but this seemed as good as any place to post seeing how I don't have a clue what the issue is.
Thanks in advance!
May 9th, 2012, 08:56 AM
Judging by the behavior you have a misconfigured transaction setup (or no transactions at all) leaving connections open and depleting your connection pool.
May 9th, 2012, 09:03 AM
Thanks for the suggestion!
I had considered that, but I'm surprised that if there was a pooling issue that an exception wouldn't get thrown. Also, just out of curiosity, even if I didn't have pooled connections, wouldn't the one connection that's available be freed and available after each database call? I would think that my application would hang momentarily while the connection is being used and then continue on after all the database calls have completed (basically, the one connection would just act as a bottle neck).
Thanks again! I'll investigate and let you know what I find.
Originally Posted by Marten Deinum
May 9th, 2012, 09:08 AM
Not without proper tx setup... Imagine a pool with 10 connecetions and you don't tell your application where to release the connection (in this case hibernate session which also uses a connection) it will then simply wait until it times out, during the wait the connection is still checked out and unavailable for other threads... So after 10 threads (in a web environment generally 1 thread per request) your application would hang on getting a connection from the pool.
An exception will be thrown after a certain time (not sure if there are defaults) the connection cannot be acquired.
If you need some help/advice post code and configuration (when doing so use the [ code][/code ] tags).
May 9th, 2012, 03:28 PM
So I just got home and checked my setup. You were absolutely correct!
I laughed at these...
"I've noticed that as a click around my application, after about 8 - 10 link clicks, my application will hang"
I had my pool set up for 8 max active connections.
"The application will just sit there trying to load the next page forever"
The default timeout (which I was using) is infinite.
I changed my default timeout to 500ms and then I started getting exceptions about my connection. I'm going to try and add in a TransactionManager to try and resolve this issue. Thanks so much for your help!!
May 9th, 2012, 05:21 PM
Marten thanks so much for your help!! I got transaction management working (with only moderate pain) and now the connection pool seems to working appropriately.
May 10th, 2012, 01:12 AM
I really must be doing this for too long. Reading a description like yours and directly think transaction setup... Maybe time for a career switch .