I am using tomcat 7 and I have a webapp which has 1 configuration file & 1 hazelcast.xml file in tomcat bin directory. When I start tomcat as a process from startup.bat catalina.timestamp.log shows INFO: Configuring Hazelcast from 'C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\bin\hazelcast.xml'.
and everything works fine, but when I start the same webapp by starting tomcat as a windows service it goes to tomcat home dir and looks for the file here INFO: Configuring Hazelcast from 'C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\hazelcast.xml'.
Is there any jvm or tomcat option that I need to place?
below is my Java Options which is set in Tomcat properties
-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7
-Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\endorsed
-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\conf\logging.properties
I was able to solve my problem.
When I start Tomcat as a Windows service it sets the current working dir to %CATALINA_HOME%
. So I added --StartPath=%CATALINA_HOME%\bin
in service.bat
(details here) and installed a fresh service like so: service.bat install MyService
.
Incase one does not have service.bat
but tomcat6
: below is the command to create a fresh windows service.
tomcat6 //IS//MyService --DisplayName="My Service Name" \ --Install="C:\tomcat6\bin\tomcat6.exe" --Jvm=auto \ --StartMode=jvm --StopMode=jvm \ --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start \ --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop \ --StartPath=C:\tomcat6\bin
You can even set this in the Tomcat GUI: Startup
tab | Start parameters
.
(The Tomcat GUI is also known as the "Commons Daemon Service Manager". Default name is tomcat7w.exe
, or "YOURSERVICENAMEHEREw.exe".)