i want to restart my tomcat through my java code/servlet. Is there any way to do so??? ON particular Exception,i want to restart my tomcat
3 Answers
No need to run any application. In my code i m just executing my BATCH file. Here is a code for the same:
Runtime.getRuntime().exec("cmd.exe /c start C:\restart_tomcat.bat");
And following is my 'restart_tomcat.bat' file contains
C:\WINDOWS\system32\net stop TomcatServiceName
C:\WINDOWS\system32\net start TomcatServiceName
exit

- 1,129
- 3
- 16
- 23
may be you should write an external program that will execute the scripts shutdown.sh/startup.sh (CATALINA_HOME/bin) and call it when an exception occurs

- 11
- 2
If you have the manager application installed you can use it to stop and start individual deployed applications. Note that you don't want to get an application to ask the manager to stop and then restart itself for obvious reasons. Instead you could have a proxy-manager app which will would accept requests to stop and then restart other apps. Your app would then make requests to the proxy-manager.

- 18,217
- 6
- 44
- 80