Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reload tomcat context programmatically whenever java heap memory exception occurs

 
maria kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat Manager web app allows me to easily restart a web app.
So,when I got the exception like Java heap memory problem, I wanted to restart the context(or call the manager URL) programmatically.
In between any request comes to server(context) will hold up to the completion of the context restart then after process that request.

Can you guide me how to achieve the above scenario.



Thanks,
Maria.

 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the "Out of memory error" is not meant to be caught neither the JVM will be running after this error occurs. Tomcat and JVM both will be going down. So there is no way to reload the context, to be specific store the context for later reload.
If you want to queue requests when the application is down, then my guess is you need another load balancing server or a queuing server simply because the current server is not able to bear with the load its working with.

Hope this helps
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably not a good idea to try to recover from a memory exception by any shortcut - you need to restart the server.

Naturally figuring out why you got the exception and fixing it is the best long term plan.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic