Apr 18, 2017

How to keep multiple instance of tomcat running

There are two ways in which one can make use of a software one by using

1.installer (where some software helps in deploying files in appropriate places and modifying environment variables)
Microsoft Windows application uses MSI (Microsoft software installer)
Red hat based Linux uses YUM utility
Debian based Linux variant say Ubuntu uses APT utility

"But the major problem using installer is, there is no flexibility for the user to change it to suit his or her requirement"

so here comes the second way of using a software
2.Archived
Instead of downloading the installers just down load .zip .tar type software package and unpack it. now you can customize it.

1. Download Tomcat from here & unzip to any location.
2. Go to \Conf folder and take the backup of all the files (It is good practice to have the backup of original files before making any changes)
3. we are going to edit web.xml and change 'listings' param-value 'false' to 'true'.

   <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>

4. Edit server.xml if you want to run multiple instances of tomcat simultaneously connecting to different port you can do it by changing 8080 to some other value.

 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

5. Edit tomcat-users.xml and give the user name password for 'manager-gui' role (uncomment if commented).

<role rolename="manager-gui"/>
  <user username="admin" password="admin" roles="manager-gui"/>

6.Add the environmental variable 'JAVA_HOME' for Development of Java based application
or 'JRE_HOME' for just running the application purpose.

My computer - Properties -Advanced system settings - Environment variables
Ex:
variable name: JAVA_HOME
variable value: C:\Program Files\Java\jdk1.8.0_73

7. Now start the tomcat by double clicking on startup.bat
check at http://localhost:8080

8.Now stop the tomcat by double clicking on shutdown.bat