简体   繁体   中英

Restarting tomcat service through java/servlet

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

No need to run any application. In my code im 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

可能是您应该编写一个外部程序来执行脚本shutdown.sh/startup.sh(CATALINA_HOME / bin),并在发生异常时调用它

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM