4

I have tomcat 6.0.32 installed and running my web application on it. Usual stop/start works fine, when the tomcat is properly started or stopped. But when I try to stop the tomcat when it is in the middle of a startup, the stop fails.

$service tomcat6 stop

Stopping tomcat6:                                          [FAILED]

The error in the log is:

SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:422)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)

I have tried using force as well, but it doesn't work. Does anyone know how can we fix this?

Note: I was able to stop tomcat6 (6.0.24) in the middle of the startup, but it is not working in 6.0.32 version. Any help/info would be a great help!

4

1 に答える 1

4

This is to help anyone who encounters the same problem. Please bear in mind that I have no explanation of how the change works, but it solved my problem so posting it for others.

There is a function called "parseOption" in /etc/init.d/tomcat6, which parses the configurations specified in the config file. This function is being called in the other functions [stop/start], and does work fine in parsing the configs as shown in the output above.

Inside the stop function, it is originally called as follows:

   if [ -f "/var/lock/subsys/${NAME}" ]; then
      parseOptions
      $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1

I changed the above to:

 if [ -f "/var/lock/subsys/${NAME}" ]; then
    $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1
    parseOptions

and it worked. I was able to stop tomcat in the middle of a start up and otherwise. The rest of the stop function is executed properly as well [removing the pid file, killing the process...]. How different the implementation is when the tomcat is in started mode or starting up, is unclear, since regular stop works fine without any changes, in the started mode.

于 2011-06-29T09:13:24.963 に答える