You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John A Parker <jo...@cornell.edu> on 2010/07/22 17:02:57 UTC

Connection Refused On Tomcat Server Shutdowns if...

Using apache-tomcat-6.0.28...

We are encountering issue with "catalina.sh stop"s IF we use a variable to set the SHUTDOWN port.

e.g.:
CATALINA_OPTS = "...-Dco.shutdown.port=8104 ..."
server.xml =    "...
                 <!-
                 <Server port="8104" shutdown="SHUTDOWN">
                 -->
                 <Server port="${co.shutdown.port}" shutdown="SHUTDOWN">
                 ..."


After startup we see...

...
java     24389 tcowner   42u  IPv6 8406404       TCP localhost.localdomain:8104 (LISTEN)


But on shutdown we get...

SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at java.net.Socket.<init>(Socket.java:375)
        at java.net.Socket.<init>(Socket.java:189)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)
Tomcat did not stop in time. PID file was not removed.


IF however I swap the server.xml SHUTDOWN port lines shown above then the catalina.sh stop works as it should.


Any ideas on why the dynamic port definition works on startup but not on shutdown?


Thanks in advance,

John A Parker
Cornell University
(607) 255-9356
john.a.parker@cornell.edu<ma...@cornell.edu>


Re: Connection Refused On Tomcat Server Shutdowns if...

Posted by Rainer Jung <ra...@kippdata.de>.
On 22.07.2010 17:24, David Fisher wrote:
> If you look at catalina.sh you will see that stop does not include CATALINA_OPTS:
>
>    "$_RUNJAVA" $JAVA_OPTS \
>      -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
>      -Dcatalina.base="$CATALINA_BASE" \
>      -Dcatalina.home="$CATALINA_HOME" \
>      -Djava.io.tmpdir="$CATALINA_TMPDIR" \
>      org.apache.catalina.startup.Bootstrap "$@" stop
>
> Change your catalina.sh to include your CATALINA_OPTS and it ought to work.
>
> Looks like a "bug" in Tomcat to me.

Feature, not a bug. There are options that you actually do not want to 
occur for start and stop, e.g. assume you assign 1GB of heap per 
commandline parameter. If the same parameter were used for stopping, the 
shutdown process that lives only a few milliseconds to connect to the 
shutdown port of Tomcat would also be started with this huge memory 
size, although it doesn't need it. Another example is using a JMX port. 
If you use the same flag for the shutdown process, the JVM will not 
initialize, because it can not bind to the JMX port already in use.

This has been introduced in 6.0.15, see

https://issues.apache.org/bugzilla/show_bug.cgi?id=42951

Rainer

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


Re: Connection Refused On Tomcat Server Shutdowns if...

Posted by David Fisher <df...@jmlafferty.com>.
If you look at catalina.sh you will see that stop does not include CATALINA_OPTS:

  "$_RUNJAVA" $JAVA_OPTS \
    -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
    -Dcatalina.base="$CATALINA_BASE" \
    -Dcatalina.home="$CATALINA_HOME" \
    -Djava.io.tmpdir="$CATALINA_TMPDIR" \
    org.apache.catalina.startup.Bootstrap "$@" stop

Change your catalina.sh to include your CATALINA_OPTS and it ought to work.

Looks like a "bug" in Tomcat to me.

Regards,
Dave

On Jul 22, 2010, at 8:02 AM, John A Parker wrote:

> Using apache-tomcat-6.0.28...
> 
> We are encountering issue with "catalina.sh stop"s IF we use a variable to set the SHUTDOWN port.
> 
> e.g.:
> CATALINA_OPTS = "...-Dco.shutdown.port=8104 ..."
> server.xml =    "...
>                 <!-
>                 <Server port="8104" shutdown="SHUTDOWN">
>                 -->
>                 <Server port="${co.shutdown.port}" shutdown="SHUTDOWN">
>                 ..."
> 
> 
> After startup we see...
> 
> ...
> java     24389 tcowner   42u  IPv6 8406404       TCP localhost.localdomain:8104 (LISTEN)
> 
> 
> But on shutdown we get...
> 
> SEVERE: Catalina.stop:
> java.net.ConnectException: Connection refused
>        at java.net.PlainSocketImpl.socketConnect(Native Method)
>        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
>        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
>        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
>        at java.net.Socket.connect(Socket.java:529)
>        at java.net.Socket.connect(Socket.java:478)
>        at java.net.Socket.<init>(Socket.java:375)
>        at java.net.Socket.<init>(Socket.java:189)
>        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
>        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)
> Tomcat did not stop in time. PID file was not removed.
> 
> 
> IF however I swap the server.xml SHUTDOWN port lines shown above then the catalina.sh stop works as it should.
> 
> 
> Any ideas on why the dynamic port definition works on startup but not on shutdown?
> 
> 
> Thanks in advance,
> 
> John A Parker
> Cornell University
> (607) 255-9356
> john.a.parker@cornell.edu<ma...@cornell.edu>
> 


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


RE: Connection Refused On Tomcat Server Shutdowns if...

Posted by John A Parker <jo...@cornell.edu>.
Rainer, et al,

Obvious (now that you point it out! (:-\).

Moving my settings to JAVA_OPTS corrected the behavior.

THANKS TO ALL!

John
Cornell University
(607) 255-9356
john.a.parker@cornell.edu

-----Original Message-----
From: Rainer Jung [mailto:rainer.jung@kippdata.de] 
Sent: Thursday, July 22, 2010 11:27 AM
To: Tomcat Users List
Subject: Re: Connection Refused On Tomcat Server Shutdowns if...

On 22.07.2010 17:02, John A Parker wrote:
> Using apache-tomcat-6.0.28...
>
> We are encountering issue with "catalina.sh stop"s IF we use a variable to set the SHUTDOWN port.
>
> e.g.:
> CATALINA_OPTS = "...-Dco.shutdown.port=8104 ..."
> server.xml =    "...
>                   <!-
>                   <Server port="8104" shutdown="SHUTDOWN">
>                   -->
>                   <Server port="${co.shutdown.port}" shutdown="SHUTDOWN">
>                   ..."
>
>
> After startup we see...
>
> ...
> java     24389 tcowner   42u  IPv6 8406404       TCP localhost.localdomain:8104 (LISTEN)
>
>
> But on shutdown we get...
>
> SEVERE: Catalina.stop:
> java.net.ConnectException: Connection refused
>          at java.net.PlainSocketImpl.socketConnect(Native Method)
>          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
>          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
>          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
>          at java.net.Socket.connect(Socket.java:529)
>          at java.net.Socket.connect(Socket.java:478)
>          at java.net.Socket.<init>(Socket.java:375)
>          at java.net.Socket.<init>(Socket.java:189)
>          at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408)
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>          at java.lang.reflect.Method.invoke(Method.java:597)
>          at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
>          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)
> Tomcat did not stop in time. PID file was not removed.
>
>
> IF however I swap the server.xml SHUTDOWN port lines shown above then the catalina.sh stop works as it should.
>
>
> Any ideas on why the dynamic port definition works on startup but not on shutdown?

CATALINA_OPTS is only used during startup. If you want to add parameters 
for startup and shutdown, use JAVA_OPTS. See also the comments at the 
beginning of catalina.(sh|bat).

Regards,

Rainer


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


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


Re: Connection Refused On Tomcat Server Shutdowns if...

Posted by Rainer Jung <ra...@kippdata.de>.
On 22.07.2010 17:02, John A Parker wrote:
> Using apache-tomcat-6.0.28...
>
> We are encountering issue with "catalina.sh stop"s IF we use a variable to set the SHUTDOWN port.
>
> e.g.:
> CATALINA_OPTS = "...-Dco.shutdown.port=8104 ..."
> server.xml =    "...
>                   <!-
>                   <Server port="8104" shutdown="SHUTDOWN">
>                   -->
>                   <Server port="${co.shutdown.port}" shutdown="SHUTDOWN">
>                   ..."
>
>
> After startup we see...
>
> ...
> java     24389 tcowner   42u  IPv6 8406404       TCP localhost.localdomain:8104 (LISTEN)
>
>
> But on shutdown we get...
>
> SEVERE: Catalina.stop:
> java.net.ConnectException: Connection refused
>          at java.net.PlainSocketImpl.socketConnect(Native Method)
>          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
>          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
>          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
>          at java.net.Socket.connect(Socket.java:529)
>          at java.net.Socket.connect(Socket.java:478)
>          at java.net.Socket.<init>(Socket.java:375)
>          at java.net.Socket.<init>(Socket.java:189)
>          at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408)
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>          at java.lang.reflect.Method.invoke(Method.java:597)
>          at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
>          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)
> Tomcat did not stop in time. PID file was not removed.
>
>
> IF however I swap the server.xml SHUTDOWN port lines shown above then the catalina.sh stop works as it should.
>
>
> Any ideas on why the dynamic port definition works on startup but not on shutdown?

CATALINA_OPTS is only used during startup. If you want to add parameters 
for startup and shutdown, use JAVA_OPTS. See also the comments at the 
beginning of catalina.(sh|bat).

Regards,

Rainer


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