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.
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.
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.
Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.
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.
What are you saying? I thought you said that Santa gave you that. And this tiny ad: