Hello,

we are running Tomcat 9.0.62 on AIX 7.2. In our server.xml we use variables for 
ports and other values:

<Server port="${port.shutdown}" shutdown="SHUTDOWN">
...

The variables are set in setenv.sh (the port is an example):

export CATALINA_OPTS="-Dport.shutdown=12345 $CATALINA_OPTS"

Tomcat is starting with this configuration and working correctly, but when 
Tomcat is stopped with shutdown.sh we get the following error:

The stop command failed. Attempting to signal the process to stop through OS 
signal.
Tomcat stopped.
May 05, 2022 8:26:38 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0]). 
Tomcat may not be running.
May 05, 2022 8:26:38 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Error stopping Catalina
java.net.ConnectException: A remote host refused an attempted connect 
operation. (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at 
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:380)
        at 
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:236)
        at 
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:218)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
        at java.net.Socket.connect(Socket.java:682)
        at java.net.Socket.connect(Socket.java:622)
        at java.net.Socket.<init>(Socket.java:485)
        at java.net.Socket.<init>(Socket.java:255)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:667)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
        at java.lang.reflect.Method.invoke(Method.java:508)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:391)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:481)

Despite this error message Tomcat is stopped, but this is still bad for 
monitoring purposes and irritates support. The port 8005 is not configured in 
the server.xml and it is not in use (we checked with netstat).

We have done some investigation and found out:

1. When ${port.shutdown} in server.xml is replaced with the real integer port 
value 12345 the error does not show up (but we cannot use the variable)
2. When we send the shutdown command to port 12345 (e.g. with telnet) Tomcat 
stops without errors (but we cannot use shutdown.sh)
3. We attached to the Tomcat JMX port, checked the mbeans and they return the 
correct values:
$>get -b Catalina:type=Server port
#mbean = Catalina:type=Server:
port = 12345;
$>get -b Catalina:type=Server serverInfo
#mbean = Catalina:type=Server:
serverInfo = Apache Tomcat/9.0.62;
$>get -b Catalina:type=Server serverNumber
#mbean = Catalina:type=Server:
serverNumber = 9.0.62.0;
$>get -b Catalina:type=Server address
#mbean = Catalina:type=Server:
address = localhost;
$>get -b Catalina:type=Server shutdown
#mbean = Catalina:type=Server:
shutdown = SHUTDOWN;
$>get -b Catalina:type=Server sateName
#mbean = Catalina:type=Server:
$>get -b Catalina:type=Server portWithOffset
#mbean = Catalina:type=Server:
portWithOffset = 12345;

Do you have any idea, why this error message happens and how we can get rid of 
it, when using variables in server.xml for the shutdown port.

Regards 
Henning

INTERNAL

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to