You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Derek Suzuki <ds...@teleias.com> on 2001/12/06 01:59:15 UTC

Using inet parameter with StopTomcat in 3.2.3

	I have configured several connectors in server.xml with the "inet"
parameter, allowing them to bind to a single IP address.  This seems to work
fine, but it causes shutdown.sh to fail.  It seems that StopTomcat uses the
hardcoded hostname "localhost" when establishing a socket connection to the
Ajp12 connector.  I got around this by adding a getAddr() method to
PoolTcpConnector.java and using the return value in StopTomcat.
	This was with Tomcat 3.2.3, but it looks like 3.2.4 does the same
thing.  If anyone else is facing this problem (and I'm not just totally
missing the correct procedure), the following diffs resolved the problem for
me.

diff -u -p -r1.1 -r1.2
--- PoolTcpConnector.java       2001/11/06 00:40:29     1.1
+++ PoolTcpConnector.java       2001/12/06 00:13:26     1.2
@@ -227,6 +227,10 @@ public final class PoolTcpConnector impl
        return port;
     }

+    public String getAddr() {
+        return address.getHostAddress();
+    }
+
     /** Generic configure system - this allows Connector
      *         configuration using name/value.
      *


diff -u -p -r1.1 -r1.2
--- StopTomcat.java     2001/11/06 00:40:34     1.1
+++ StopTomcat.java     2001/12/06 00:13:26     1.2
@@ -87,6 +87,7 @@ public class StopTomcat {
     {
        // Find Ajp12 connector
        int portInt=8007;
+       String inetStr="localhost";
        Enumeration enum=cm.getConnectors();
        while( enum.hasMoreElements() ) {
            Object con=enum.nextElement();
@@ -95,13 +96,14 @@ public class StopTomcat {
                if( tcpCon.getTcpConnectionHandler()
                    instanceof Ajp12ConnectionHandler ) {
                    portInt=tcpCon.getPort();
+                   inetStr=tcpCon.getAddr();
                }
            }
        }

        // use Ajp12 to stop the server...
        try {
-           Socket socket = new Socket("localhost", portInt);
+           Socket socket = new Socket(inetStr, portInt);
            OutputStream os=socket.getOutputStream();
            byte stopMessage[]=new byte[2];
            stopMessage[0]=(byte)254;

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>