I am running multiple Tomcat
instances on the same host and have installed them as windows services. Of course this is with distinct ports for each of the Tomcat
instances. Now I am trying to extract the port numbers out of server.xml
file and trying to pass them as JVM options, so that the server.xml
file looks the same for all the Tomcat
instances. Currently the Connector port in my server.xml
file for each instance looks like:
Instance 1
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Instance 2
<Connector port="8180" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
and I am trying to make it look like
<Connector port="${port.http}" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
As mentioned in this answer, I can edit the options manually to add the parameter -Dport.http=8080
or -Dport.http=8180
and it works fine, but what I need is this JVM option to be set when Tomcat
is installed as a windows service.
Below is the content of the .bat
file I am running to install Tomcat
instance1 as windows service (Its the same for instance2 except CATALINA_BASE, port and service name). As you see, I am also trying to set JAVA_OPTS
before it is installed as a service, but I don't seem to have any luck with this. I have also tried it with double-quotes like CALL SET "JAVA_OPTS=-Dport.http=8080"
and CALL SET JAVA_OPTS="-Dport.http=8080"
CALL SET JAVA_HOME=D:\Java
CALL SET CATALINA_BASE=D:\instance1
CALL SET JAVA_OPTS=-Dport.http=8080
CALL CD %CATALINA_HOME%\bin
service install instance1
Can anyone help please?