Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

tomcat

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"]
like image 972
vishal Avatar asked Jul 23 '14 07:07

vishal


People also ask

How to verify Tomcat is running?

Use a browser to check whether Tomcat is running on URL http://localhost:8080 , where 8080 is the Tomcat port specified in conf/server. xml. If Tomcat is running properly and you specified the correct port, the browser displays the Tomcat homepage.

How to check Tomcat running or not in linux?

A simple way to see if Tomcat is running is to check if there is a service listening on TCP port 8080 with the netstat command. This will, of course, only work if you are running Tomcat on the port you specify (its default port of 8080, for example) and not running any other service on that port.


2 Answers

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

like image 78
vzamanillo Avatar answered Nov 05 '22 23:11

vzamanillo


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.

like image 31
JohannSig Avatar answered Nov 05 '22 22:11

JohannSig