You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Boesch, Henning (G-GPPD)" <he...@vwgis.de> on 2022/05/05 06:42:06 UTC

Variables in server.xml leads to error when stopping Tomcat

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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: AW: Variables in server.xml leads to error when stopping Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Henning,

On 5/5/22 09:27, Boesch, Henning (G-GPPD) wrote:
> Hello Torsten, hello Chris
> 
>> You need to put "-Dport.shutdown=12345" to the JAVA_OPTS because the
>> stop process needs that port.
> 
> Thanks for the answer, this worked for me.
> 
>> Henning, the reason you get the error message and Tomcat /still/ stops is because the shutdown process uses an OS signal if the "normal" way doesn't work. So it's not just a spurious error message: it's real.
> 
> Thanks for the explanation, I was just confused, because the variable was replaced correctly

On startup only.

> and sending the shutdown command manually did also work.

Because the port was bound properly on startup, "telnet" always works.

The port number wasn't available on shutdown because the system property 
was only set for startup, not shutdown. For "telnet", you were 
manually-providing the port number on the command-line :)

Thanks,
-chris

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


AW: Variables in server.xml leads to error when stopping Tomcat

Posted by "Boesch, Henning (G-GPPD)" <he...@vwgis.de>.
Hello Torsten, hello Chris

> You need to put "-Dport.shutdown=12345" to the JAVA_OPTS because the 
> stop process needs that port.

Thanks for the answer, this worked for me.

> Henning, the reason you get the error message and Tomcat /still/ stops is because the shutdown process uses an OS signal if the "normal" way doesn't work. So it's not just a spurious error message: it's real.

Thanks for the explanation, I was just confused, because the variable was replaced correctly and sending the shutdown command manually did also work.

Regards
Henning

INTERNAL

Re: Variables in server.xml leads to error when stopping Tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Torsten,

On 5/5/22 04:14, Torsten Krah wrote:
> Am Donnerstag, dem 05.05.2022 um 06:42 +0000 schrieb Boesch, Henning
> (G-GPPD):
>> export CATALINA_OPTS="-Dport.shutdown=12345 $CATALINA_OPTS"
> 
> The docs have this:
> 
> #   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
> #                   "run" or "debug" command is executed.
> #                   Include here and not in JAVA_OPTS all options, that should
> #                   only be used by Tomcat itself, not by the stop process,
> #                   the version command etc.
> #                   Examples are heap size, GC logging, JMX ports etc
> 
> You need to put "-Dport.shutdown=12345" to the JAVA_OPTS because the
> stop process needs that port.

+1

Henning, the reason you get the error message and Tomcat /still/ stops 
is because the shutdown process uses an OS signal if the "normal" way 
doesn't work. So it's not just a spurious error message: it's real.

-chris

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


Re: Variables in server.xml leads to error when stopping Tomcat

Posted by Torsten Krah <kr...@gmail.com>.
Am Donnerstag, dem 05.05.2022 um 06:42 +0000 schrieb Boesch, Henning
(G-GPPD):
> export CATALINA_OPTS="-Dport.shutdown=12345 $CATALINA_OPTS"

The docs have this:

#   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
#                   "run" or "debug" command is executed.
#                   Include here and not in JAVA_OPTS all options, that should
#                   only be used by Tomcat itself, not by the stop process,
#                   the version command etc.
#                   Examples are heap size, GC logging, JMX ports etc

You need to put "-Dport.shutdown=12345" to the JAVA_OPTS because the
stop process needs that port.

Torsten



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