I have two tomcats Installed as below:

1. Tomcat-A {Path : C:\TomcatA , Ports : Connector port="8080"
redirectPort="8443" shutdown port as -1}
2. Tomcat-B {Path : C:\TomcatB , Ports : Connector port="8090"
redirectPort="8444" shutdown port as 8015}

I have a JSP/Servlet Applications which runs on Tomcat-A. My requirement is to shutdown Tomcat-B and delete/undeploy application hosted on Tomcat-B. Below is my Java code.

```
private void StopTomcat() throws Exception {
    if(logger.isDebugEnabled()) logger.debug("StopTomcat");

    try {

        if (logger.isTraceEnabled())logger.trace("Shutting down tomcat: ");

        String Directory = "C:\TomcatB\bin\";

        Process process = Runtime.getRuntime().exec(Directory + "shutdown.bat");

        if (logger.isTraceEnabled())logger.trace("Executed shutdown.bat at " + Directory );

        BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
        BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

        if (logger.isTraceEnabled())logger.trace("Printing shutdown process logs" );
        String s = null;
        while ((s = stdInput.readLine()) != null) {
            if (logger.isTraceEnabled())
                logger.trace(s);
        }
        String Error = "";
        while ((s = stdError.readLine()) != null) {
            Error = Error + s;
        }

        if (!Error.equals("")) {
            logger.error(Error);
            throw new Exception("Tomcat Shutdown Failed with error: " + Error);
        }

    } catch (Exception e) {
        e.printStackTrace();
        logger.error( Arrays.toString( e.getStackTrace() ));
        throw new Exception(e.getMessage());
    }
}

```

And in the logs I get:

```
2020-08-04 21:11:00 TRACE MigrateApp:55 - Executed shutdown.bat at C:\TomcatB\bin\
2020-08-04 21:11:00 TRACE MigrateApp:60 - Printing shutdown process logs
2020-08-04 21:11:00 TRACE MigrateApp:64 - Using CATALINA_BASE:   "TomcatA"
2020-08-04 21:11:00 TRACE MigrateApp:64 - Using CATALINA_HOME:   "TomcatA"
2020-08-04 21:11:00 TRACE MigrateApp:64 - Using CATALINA_TMPDIR: "TomcatA\temp"
2020-08-04 21:11:00 TRACE MigrateApp:64 - Using JRE_HOME:        "C:\Program Files\Java\jre1.8.0_251"
2020-08-04 21:11:00 TRACE MigrateApp:64 - Using CLASSPATH:       "TomcatA\bin\bootstrap.jar;TomcatA\bin\tomcat-juli.jar"
2020-08-04 21:11:00 ERROR MigrateApp:72 - 04-Aug-2020 21:11:00.668 SEVERE [main] org.apache.catalina.startup.Catalina.stopServer No shutdown port configured. Shut down server through OS signal. Server not shut down.
2020-08-04 21:11:00 ERROR MigrateApp:78 - [sailpoint.support.applicationdeployer.util.MigrateApp.StopTomcat(MigrateApp.java:73), sailpoint.support.applicationdeployer.util.MigrateApp.run(MigrateApp.java:36)]
2020-08-04 21:11:00 ERROR MigrateApp:79 - Tomcat Shutdown Failed with error: 04-Aug-2020 21:11:00.668 SEVERE [main] org.apache.catalina.startup.Catalina.stopServer No shutdown port configured. Shut down server through OS signal. Server not shut down.
2020-08-04 21:11:00 ERROR MigrateApp:39 - Tomcat Shutdown Failed with error: 04-Aug-2020 21:11:00.668 SEVERE [main] org.apache.catalina.startup.Catalina.stopServer No shutdown port configured. Shut down server through OS signal. Server not shut down.

```

I am not able to understand why my code is trying to shutdown Tomcat-A. Can anyone please help me on the same.