Tomcat 关闭报错:Tomcat did not stop in time. PID file w(2)

[root@ptbin]# vim shutdown.sh
exec "$PRGDIR"/"$EXECUTABLE" stop "$@" 
#改成如下
exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@"
#然后再执行shutdown.sh操作,ok,就不会报错,正常执行完毕了。1
查看执行结果如下:

[root@ptbin]# ./shutdown.sh
Using CATALINA_BASE:  /usr/local/app/apache-tomcat-6.0.37_9300
Using CATALINA_HOME:  /usr/local/app/apache-tomcat-6.0.37_9300
Using CATALINA_TMPDIR: /usr/local/app/apache-tomcat-6.0.37_9300/temp
Using JRE_HOME:        /usr/lib/jvm/java
Using CLASSPATH:      /usr/local/app/apache-tomcat-6.0.37_9300/bin/bootstrap.jar
Using CATALINA_PID:    /var/tomcat/9300.pid
[root@ptbin]#

3.3 通过bash -x分析真正的原因
3.3.1 先查看执行报错的时候的bash过程
    [root@ptbin]# bash -x catalina.sh stop
    + JAVA_OPTS='-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+PrintGCDetails -Xloggc:/logs/gc/9300.gc'
    + CATALINA_PID=/var/tomcat/9300.pid
    + cygwin=false
    + os400=false
    + darwin=false
    + case "`uname`" in
    ++ uname
    + PRG=catalina.sh
    + '[' -h catalina.sh ']'
    ++ dirname catalina.sh
    + PRGDIR=.
    + '[' -z '' ']'
    ++ cd ./..
    ++ pwd
    + CATALINA_HOME=/usr/local/app/apache-tomcat-6.0.37_9300
    + '[' -z '' ']'
    + CATALINA_BASE=/usr/local/app/apache-tomcat-6.0.37_9300
    + CLASSPATH=
    + '[' -r /usr/local/app/apache-tomcat-6.0.37_9300/bin/setenv.sh ']'
    + '[' -r /usr/local/app/apache-tomcat-6.0.37_9300/bin/setenv.sh ']'
    + false
    + false
    + false
    + '[' -r /usr/local/app/apache-tomcat-6.0.37_9300/bin/setclasspath.sh ']'
    + BASEDIR=/usr/local/app/apache-tomcat-6.0.37_9300
    + . /usr/local/app/apache-tomcat-6.0.37_9300/bin/setclasspath.sh
    ++ '[' -z /usr/lib/jvm/java -a -z '' ']'
    ++ '[' -z /usr/lib/jvm/java -a stop = debug ']'
    ++ '[' -z '' ']'
    ++ JRE_HOME=/usr/lib/jvm/java
    ++ '[' stop = debug ']'
    ++ '[' -z /usr/local/app/apache-tomcat-6.0.37_9300 ']'
    ++ '[' '!' -x /usr/local/app/apache-tomcat-6.0.37_9300/bin/setclasspath.sh ']'
    ++ '[' -z '' ']'
    ++ JAVA_ENDORSED_DIRS=/usr/local/app/apache-tomcat-6.0.37_9300/endorsed
    ++ JIKESPATH=
    +++ uname -s
    ++ '[' Linux = Darwin ']'
    ++ _RUNJAVA=/usr/lib/jvm/java/bin/java
    ++ '[' false '!=' true ']'
    ++ _RUNJDB=/usr/lib/jvm/java/bin/jdb
    + '[' -z /usr/local/app/apache-tomcat-6.0.37_9300 ']'
    + '[' '!' -z '' ']'
    + '[' /usr/local/app/apache-tomcat-6.0.37_9300 '!=' /usr/local/app/apache-tomcat-6.0.37_9300 ']'
    + CLASSPATH=/usr/local/app/apache-tomcat-6.0.37_9300/bin/bootstrap.jar
    + '[' -z '' ']'
    + CATALINA_OUT=/usr/local/app/apache-tomcat-6.0.37_9300/logs/catalina.out
    + '[' -z '' ']'
    + CATALINA_TMPDIR=/usr/local/app/apache-tomcat-6.0.37_9300/temp
    + have_tty=0
    ++ tty
    + '[' /dev/pts/1 '!=' 'not a tty' ']'
    + have_tty=1
    + false
    + '[' -z '' ']'
    + '[' -r /usr/local/app/apache-tomcat-6.0.37_9300/conf/logging.properties ']'
    + LOGGING_CONFIG=-Djava.util.logging.config.file=/usr/local/app/apache-tomcat-6.0.37_9300/conf/logging.properties
    + '[' -z '' ']'
    + LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    + '[' 1 -eq 1 ']'
    + echo 'Using CATALINA_BASE:  /usr/local/app/apache-tomcat-6.0.37_9300'
    Using CATALINA_BASE:  /usr/local/app/apache-tomcat-6.0.37_9300
    + echo 'Using CATALINA_HOME:  /usr/local/app/apache-tomcat-6.0.37_9300'
    Using CATALINA_HOME:  /usr/local/app/apache-tomcat-6.0.37_9300
    + echo 'Using CATALINA_TMPDIR: /usr/local/app/apache-tomcat-6.0.37_9300/temp'
    Using CATALINA_TMPDIR: /usr/local/app/apache-tomcat-6.0.37_9300/temp
    + '[' stop = debug ']'
    + echo 'Using JRE_HOME:        /usr/lib/jvm/java'
    Using JRE_HOME:        /usr/lib/jvm/java
    + echo 'Using CLASSPATH:      /usr/local/app/apache-tomcat-6.0.37_9300/bin/bootstrap.jar'
    Using CLASSPATH:      /usr/local/app/apache-tomcat-6.0.37_9300/bin/bootstrap.jar
    + '[' '!' -z /var/tomcat/9300.pid ']'
    + echo 'Using CATALINA_PID:    /var/tomcat/9300.pid'
    Using CATALINA_PID:    /var/tomcat/9300.pid
    + '[' stop = jpda ']'
    + '[' stop = debug ']'
    + '[' stop = run ']'
    + '[' stop = start ']'
    + '[' stop = stop ']'
    + shift
    + SLEEP=5
    + '[' '!' -z '' ']'
    + FORCE=0
    + '[' '' = -force ']'
    + '[' '!' -z /var/tomcat/9300.pid ']'
    + '[' -f /var/tomcat/9300.pid ']'
    + '[' -s /var/tomcat/9300.pid ']'
    ++ cat /var/tomcat/9300.pid
    + kill -0 23430
    + '[' 0 -gt 0 ']'
    + echo 0000002
    0000002
    + /usr/lib/jvm/java/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms512m -Xmx1024m -Xss1024K -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+PrintGCDetails -Xloggc:/logs/gc/9300.gc -Djava.endorsed.dirs=/usr/local/app/apache-tomcat-6.0.37_9300/endorsed -classpath /usr/local/app/apache-tomcat-6.0.37_9300/bin/bootstrap.jar -Dcatalina.base=/usr/local/app/apache-tomcat-6.0.37_9300 -Dcatalina.home=/usr/local/app/apache-tomcat-6.0.37_9300 -Djava.io.tmpdir=/usr/local/app/apache-tomcat-6.0.37_9300/temp org.apache.catalina.startup.Bootstrap stop
    Jun 13, 2015 9:27:51 AM org.apache.catalina.startup.Catalina stopServer
    SEVERE: Catalina.stop:
    java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:208)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:422)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4f0bdba19ba516edd3c44a3991017896.html