wood burning stoves*
The moose likes Tomcat and the fly likes Tomcat causing application to hang Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat causing application to hang" Watch "Tomcat causing application to hang" New topic
Author

Tomcat causing application to hang

Kumar Sonu
Ranch Hand

Joined: Apr 05, 2011
Posts: 36
I have a Struts 2 application deployed on Tomcat 6. I am facing an issue with a form which has a text field and a button. The button click action persists some data to the database.

I came across a problem today when I am invoking the action(button click) multiple times.
For e.g: Clicking the button 5-6 times. This causes my application to hang and I am not able to navigate to any other page in the application. Even re-starting the browser does help and my application gets into a some kind of a never ending deadlock ..

When I stop the tomcat server I get the following log messages on tomcat console:


After re-starting the server the application starts fine but the same problem reoccurs when I do the same action again (hitting the button 5-6 times).

Guys please help me to get rid of this issue.

Note:
I initially suspected the my database logic was causing some problem. So get rid of all db code and just did the following steps:
1. Created a form in the application with just one text field and a button
2. The action of the button was to hit some java code and print a success message on the jsp. (No db logic here)
3. When I hit the button more than 5-6 times my application hangs again.

SCJP,SCWCD, SCDJWS
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

I wouldn't say that Tomcat is causing the application to hang. More likely that the application itself is making the application hang.

Do you by any chance have any member (instance) variables in the action processor class? I've seen people do this. Or for that matter, are there class variables?

The problem is that Struts action processors are not thread-unique. Or, more plainly, only one instance of the action processor is created, and when you send multiple requests to it, whether from multiple users or simply one twitchy user who hits the submit button faster than the processor can run to completion, there's a possibility that one thread can muck up the state of the object for another thread, with unpredictable results.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kumar Sonu
Ranch Hand

Joined: Apr 05, 2011
Posts: 36
Thanks Tim.

I solved the problem after spending 2.5 days on it.
This was something to do with the usage of MyBatis FMK in my application. Basically happenned due to multiple people working on the code ..

In MyBatis we used a logic were we had opened SqlSession () but somehow forgot to close the session and hence the issue ...

The other parts of the application had used the session object correctly by instantiating the object via dependency injection. By doing this we don't need to open and close session explicity. The fmk takes care of it.

And on the better part of 2.5 days I looked into the code which was using the object correctly .. .

Anyway .. thanks again for the inputs.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat causing application to hang