vishal
vishal

Reputation: 4083

Tomcat 7 doesn't shut down, process keeps running?

I started tomcat 7 using,

cd /opt/tomcat7/bin    
$/opt/tomcat7/bin ./startup.sh

It shows process running

root     23206  130  3.4 1323956 572880 pts/2  Sl   07:58   1:05 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dspring.profiles.active=mongo1,maxListenersAllowed -DST_SERVER=mongo1 -Djava.endorsed.dirs=/opt/tomcat7/endorsed -classpath /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat7 -Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp org.apache.catalina.startup.Bootstrap start

If I shutdown it using

$/opt/tomcat7/bin ./shutdown.sh

It gives this message

Using CATALINA_BASE:   /opt/tomcat7
Using CATALINA_HOME:   /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar

but if I check the above process, it still shows it running. Tomcat doesn't shut down. I tried it using root user as well but still no success.

Manully I can kill the process but I want to create deploy script so want to do it using shutdown.sh and startup.sh

Same happens if I try using

/opt/tomcat7/bin/catalina.sh start
/opt/tomcat7/bin/catalina.sh stop

Log

Jul 23, 2014 8:26:17 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 361 ms
Jul 23, 2014 8:26:18 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 23, 2014 8:26:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/docs
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/manager
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/ROOT
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/examples
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/host-manager
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/target
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 862 ms
Jul 23, 2014 8:26:42 AM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:42 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

Upvotes: 12

Views: 38821

Answers (5)

Iamjahnvi
Iamjahnvi

Reputation: 1

Go to conf folder and then server.xml then change the port

<Server port="8005" shutdown="SHUTDOWN">

Upvotes: -1

user14560339
user14560339

Reputation:

Is you shutdown port set? (in /etc/tomcat9/conf/server.xml )

<Server  port="9005"  shutdown="SHUTDOWN">

Upvotes: 0

JohannSig
JohannSig

Reputation: 131

I once had the misfortune of a page running infinite redirect loops due to a faulty authentication mechanism.

It eventually slowed down the entire server, but also made it impossible for me to shut it down gracefully. In the end I had to employ brute force like vzamanillo describes.

The point being that something fishy might be running within your server's processes that won't finish properly.

Upvotes: 1

Alberto Perez
Alberto Perez

Reputation: 1077

If you are in windows, and using the portable tomcat, you can use the nircmd program tool, and close by title console window, instead of stopping by PID. When you have downloaded this tool, just do:

nircmd.exe win close title "Tomcat"

Upvotes: 1

vzamanillo
vzamanillo

Reputation: 10404

You can force the shutdown by PID.

Edit

..tomcat/bin/catalina.sh

and set the

CATALINA_PID=path

variable to a local path.

CATALINA_PID

(Optional) Path of the file which should contains the pid of the catalina startup java process, when start (fork) is used

then you can shutdown Tomcat with -force flag

../tomcat/bin/shutdown.sh -force

If the script can not stop Tomcat normally will use a kill to stop the process by PID.

Update:

According to Joshua Taylor comment, the recommended way to store additional variables for running tomcat is the setenv.* script.

Take a look at (3.4) Using the "setenv" script (optional, recommended) section in the tomcat running docs

https://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt

Upvotes: 14

Related Questions