Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Reload tomcat from the code?

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
container:either tomcat or oc4j
technology: servlet
OS: winxp pro
How I can Reload tomcat from the code?
I wanted to use Runtime.exec("Tomcat/bin/shutdown") and thenstartup.
But it is so obvious after shutting down there is no possibility to run the second line of code.
Possible sollutions:
1-A restart exe file in the container?
2-Any technique to do this with java?
Thank you for your help.
Best Regards,
Pourang Emami
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one way along those lines is to write a perl script that first stops the service and then starts it again and then just invoke that from java. however that may lead to problems if the service fails to come back up. there are various admin features that a provided with the latest tomcat version under /manager and /admin you might be able to look at the source of these and find a better way.
 
Pourang Emami
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim, I am still trying to find a way within java.
Thanks.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to restart Tomcat? It used to be necessary after serious changes to the code but the management interface is much improved.
If you really have to - note that you will have to do much more than exec the shutdown bat - you will have to read the output of that process until it is finished, then exec the startup.
Bill
 
Pourang Emami
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you William
A very good suggestion.
Best Regards,
Pourang Emami
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just off the top of my head....there is a admin application that comes with tomcat which is web based. Maybe you could remotely call a servlet/jsp in that admin app and request a restart?
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that admin app is hosted within the JVM you're trying to restart.

There does not exist any internals that allows a running instance of Tomcat to be entirely reloaded within that same JVM. This changes (so I've heard) in Tomcat 5.x, which uses a jakarta commons daemon project. There was a discussion about Tomcat being more 'self healing' and restarting itself when it goes down. The response from one of the Tomcat commiters was that this would "be in Tomcat 5".

One can assume then, that it will be possible to force tomcat to reload at *any* time, not just when it goes down.

And I'm moving this from Servlets -> Apache/Tomcat
[ October 08, 2003: Message edited by: Mike Curwen ]
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic