Two Tomcat Instances for Harvest
search cancel

Two Tomcat Instances for Harvest

book

Article ID: 262633

calendar_today

Updated On:

Products

CA Harvest Software Change Manager

Issue/Introduction

The requirements for Harweb and the Rest API are such that they cannot both be installed to the same instance of Tomcat.  How can Tomcat be configured to run separate instances so that both Harweb and the Rest API can be hosted on the same server?

Environment

Release : 14.0

Resolution

The necessary steps will vary depending on which type of Tomcat installation you have.  

You should confirm the bit-level of SCM Client installed - If SCM Client is 32-bit then Java and Tomcat must also be 32-bit.  If SCM Client is 64-bit then Java and Tomcat must also be 64-bit.

If you installed Tomcat by unzipping the archive, follow these steps:

In this example, SCM Client, Java, and Tomcat have already been installed, but Harweb and Rest API have not been installed yet.

Create 2 new different folders in different locations.  These folders are for storing the instance specific configuration and other data such as logs, temp data.  Let’s say new folders are “C:/tomcatInstanceOne” and “C:/tomcatInstanceTwo“.

Copy the ‘conf’ folder into instances folders from server folder, and create other needed empty folders (bin, logs, temp, webapps, work)

Create instance specific startup.bat and shutdown.bat.  These files will be needed to start and shutdown a particular instance. The content of the files will be as below:

startup.bat
set CATALINA_HOME=C:\tomcatServer
set CATALINA_BASE=C:\tomcatInstanceOne
C:\tomcatServer\bin\startup.bat

shutdown.bat
set CATALINA_HOME=C:\tomcatServer
set CATALINA_BASE=C:\tomcatInstanceOne
C:\tomcatServer\bin\shutdown.bat

Place both files in ‘bin‘ folder inside both instance specific folders. [e.g. Create folder C:/tomcatInstanceOne/bin and copy both files].

The first property (CATALINA_HOME) points to the location of the common information shareable between all running instances, while the other property (CATALINA_BASE) points to the directory where all the instance specific information is stored.

Create setenv.bat for setting instance specific environment configuration.  Create a file called setenv.bat in the “C:\tomcatInstanceOne\bin” (and in second instance folder as well) directory to set any environment variables mentioned in C:\tomcatServer\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.
*** No environment specific configuration is needed ***

In the second tomcat instance, edit your conf\server.xml file so that the shutdown ports and HTTP connector ports are not the same  as the first tomcat instance.

In C:\tomcatInstanceOne\conf\server.xml:

<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8005" shutdown="SHUTDOWN"/>
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

In C:\tomcatInstanceTwo\conf\server.xml:

<connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8006" shutdown="SHUTDOWN"/>
<connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8101" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

To make the two separate instances run as services, copy the service.bat from the original tomcat installation’s bin folder to the bin folder for the two instances, then set the needed environment variables and execute the service.bat script from each of the instance folders


 
 

From here you can proceed to install Harweb using port 8080, and install the Rest API using port 8081
 

If you installed Tomcat with the apache-tomcat-[version].exe executable, follow these steps:

In this example, SCM Client, Java, and Tomcat and Harweb have already been installed, hosting on port 8080.

Tomcat is installed in folder C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.5

 
The Apache Tomcat 8.5 Tomcat8 service is running

 
And Harweb is accessible

 
What we will do in this case is run the Tomcat installer again, selecting a new port, new service name, and new installation folder.  Right click on apache-tomcat-8.5.84.exe and select “Run as administrator”

 
Click Next

 
Click I Agree

 
Click Next

 
On the Configuration window:
-    Change the Connector Port to 8081
-    Change the Windows Service name to REST
-    Provide login credentials for the Tomcat Administrator
-    Click Next

 
Click Next

 
Confirm the Destination Folder is new, and not the same as the installation folder for the original instance, then click Install.

 
Click Finish

 
Now we see a second installation folder

 
And a second instance of Tomcat running

 
Now, install the REST API to this second instance of Tomcat:

(Open a command prompt window in "Run as administrator" mode)

(execute the install.bat)

Once this is installed we can test the installation through a Rest API test client like YARC: