• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Tomcat server not responding(Hanging state)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I have developed a java project, which reads data from database and converts each record into xml payload and store it back in database.
Used hiberante for reading data from database and JAXB for converting data into XML.And the total records in database are 3500.
I ran my java program as standalone java program, able to read all of them and converted into xml and stored into database successfully.
And I have deployed this project as jar file into tomcat , and I ran it from UI.
Everytime it processed 1000+ records and doesnt respond after that, dont see any error, exceptions , outofmemory issues.
It doesnt neither shutdown nor responds with any message.

I had tried increasing heap memory etc, but didnt solve the issue. I googled it for couple of daya , finally gave up and looking for some little help, from where can I take it forward.
Any suggestions are helpful. Thanks in advance.

Thanks
Chandra
 
Saloon Keeper
Posts: 24295
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Chandra.

What you are describing is a batch process. Batch processes typically run for long periods of time with no human interaction. The web - and Tomcat - are the exact opposite. They are based on many incidents of human interaction with short periods of processing (humans don't want to sit around feeding the computer!) Because of this, web clients will typically time out after a certain period of time. Sometimes that can be as short as 60 seconds or so. Once timed-out, the connection between client and server breaks and even if the server processes completes, there's no longer anywhere it can send back output.

There are times when it is convenient for an interactive process to initiate, control, and/or monitor a long-running batch process. In fact, I had one that required over 10 hours to run. Just aside from the fact that this would time out virtually any browser, putting the batch process in the web application would have made it almost impossible to update the application, since an app update would kill the batch process.

What I did in this particular case was maintain an RMI server as a separate processor in the system. The webapp made RMI calls to run, monitor, and control the batch process and the 2 servers (web and RMI) ran independently (loosely-coupled).

That was an extreme case, but it is very common for shorter batch processes to be spawned as threads within the webapp server. Spawning threads cannot be done from a servlet or JSP, however - it usually "works", but it's an explicit violation of the J2EE/JEE standards and it can and will crash your webserver. So instead the recommended approach is to spawn the master control thread ("engine") for batch processing in a ServletContextListener and use synchronized method calls to allow the Servlets and JSPs to talk to the engine.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Everytime it processed 1000+ records and doesnt respond after that, dont see any error, exceptions , outofmemory issues.
It doesnt neither shutdown nor responds with any message.



When you say doesn't respond do you mean that requests to ALL web apps on the server are not answered or that requests to this particular servlet are not answered?

If this was my problem I would be using the management app to check the status of request threads and memory use.

Bill
 
Chandra Veera
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for the reply and for the detailed analysis.
Yes you are right, this is a batch process. Usually it takes 5 minutes to completethe process.
And I wanted to figure out whether it is a tomcar server issue or not? for that I have ran this batch process from another web server called Jetty,
it ran successfully with out any issue.

Tomcat server processed 1000+ records in about 2 to 3 minutes then it is not responding at all, I can not move from one page to another.
My java program is already developed with multi threaded fashion, so I cantnot use multithread in web server again.

Just trying to understand where as another web server i.e Jetty with less heap size (512MB) was able to process but why not tomcat server with more heap size(4GB)?
In my project client uses Tomcat server, so I have to go with the same server

Any ideas would be helpful...

thanks
Chandra
 
Chandra Veera
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi William,

Thanks for the reply. Server is not responding to any request, even I am not able to move from one page to another.
I am running tomcat server from eclipse, I could not get the thread dump.... I was able to get the thread dump for the java processes if it ran from eclipse.
Please suggest me how do I check the status of threads..

Thanks
Chandra
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many requests does it take to put the server in a not responding state?

On possibility for not responding is that all the request worker threads have been allocated and are stuck - but that takes a lot of requests.

Searching for "tomcat manager app how to" got google hits for various tomcat versions.

Bill
 
Chandra Veera
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi William,

There are 3500 records in the database, after processing 1000 records tomacat server not responding.
Please let me know if you need more information to help me.

Thanks
Chandra
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please pay attention. My question was:

How many requests does it take to put the server in a not responding state?



NOT how many records are in the database. In other words - after you have restarted the server, does the first request to this servlet cause the freeze or does the first request run?

Have you tried to run the management app to check the status of the threads.

Bill
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing the similar issue. I am using Tomcat 9 server in which a java api application is running. Client is consuming the api url and starts a batch process after sometime the server stops responding. Neither i can login to any other application deployed in the same tomcat server. Nothing i can see in logs too. I feel this has to do something with the Tomcat Server config. Please help
reply
    Bookmark Topic Watch Topic
  • New Topic