Is it possible to modify a certain batch file for Tomcat such that before Tomcat which is set as a web service will start would do something like checking or modifying some files?
So what we want is everytime the Tomcat Service starts, do some modifying for some specific files which is needed by the application which is hosted by tomcat.
If its possible to do it by one of the batch files in tomcat then which batch file should we modify? Any ideas would be much appreciated. By the way, we’re using tomcat 7.
Short answer: It is NOT possible, at least there is no easy way to do it, just as it was discussed on the page Shashank Kadne pointed out. Other than starting Tomcat via
startup.batscript and placing you code (or a call to your BAT file) in thesetenv.batfile in the same folder asstartup.bat.If you are trying to run applications like Jenkins, Artifactory and alike on a single Tomcat installation – as discussed on that page – a better way would be to create a Tomcat Server Instance (also known as
CATALINA_BASE) for each additional application.This way you can have each application as a Windows Service and control it as a service.
Assumptions:
You Java is installed at
C:\Program Files\Java\jdk-7.0_03.You Tomcat is installed at
C:\Program Files\Apache\Tomcat 7.You want e.g. Jenkins server to be at
C:\Program Files\My Jenkins.Start
cmd.exe, and do the following:The next command should be in a single line
You should now have the
Jenkins CIservice in your “Services” window.Deploy the Jenkins web application (
WARfile) into%CATALINA_BASE%\webapps.The steps I gave above are coming “from the the head” and are not tested, I might have missed a parameter or two. That is why there is the
%CATALINA_BASE%\bin\jenkinsw.exe– start it and tweak the parameters until the server is working.