Tomcat won't stop or restart
Asked Answered
P

15

33

I tried stopping tomcat. It failed with this message:

  • Tomcat did not stop in time. PID file was not removed.

I then tried again and got this:

  • PID file (/opt/tomcat/work/catalina.pid) found but no matching process was found. Stop aborted.

I then tried starting tomcat in debug mode and got this:

  • PID file (/opt/tomcat/work/catalina.pid) found. Is Tomcat still running? Start aborted.

I them deleted /opt/tomcat/work/catalina.pid and tried restarting and got this:

  • $CATALINA_PID was set (/opt/tomcat/work/catalina.pid) but the specified file does not exist. Is Tomcat running? Stop aborted.

Anyone know how to get tomcat restarted?

Plautus answered 11/9, 2012 at 12:23 Comment(3)
What does ps say (assuming you run Tomcat on some *nix)?Tadich
Windows by using a Linux emulator. ps returns "webadmin 24735 23900 0 13:28 pts/0 00:00:00 grep tomcat"Plautus
In the environments I know, ps -ef | grep java will give you the Tomcat instance's process ID (maybe among other Java processes). What do you see?Tadich
P
4

It seems Tomcat was actually stopped. I started it and it started fine. Thanks all.

Plautus answered 11/9, 2012 at 12:38 Comment(0)
T
9

I had this error message having started up a second Tomcat server on a Linux server.

$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.

When starting up the 2nd Tomcat I had set CATALINA_PID as asked but my mistake was to set it to a directory (I assumed Tomcat would write a default file name in there with the pid).

The fix was simply to change my CATALINA_PID to add a file name to the end of it (I chose catalina.pid from the above examples). Next I went to the directory and did a simple:

touch catalina.pid

creating an empty file of the correct name. Then when I did my shutdown.sh I got the message back saying:

PID file is empty and has been ignored.
Tomcat stopped.

I didn't have the option to kill Tomcat as the JVM was in use so I was glad I found this.

Trophoplasm answered 24/11, 2016 at 11:34 Comment(3)
What are you talking about tomcat never asks to set CATALINA_PIDMindamindanao
Not sure I understand you @PhilipRego. Are you replying to me or to #SmallChess. Sorry. Pleased elaborate.Trophoplasm
"I had set CATALINA_PID as asked" Tomcat doesn't ask you to set this.Mindamindanao
A
6

Make sure Tomcat is not currently running and the PID file is removed. Them you should start Tomcat successfully.

If you start fresh then:

  1. Create setenv.sh file in <CATALINA_HOME>/bin.
  2. In it I set CATALINA_PID=/tmp/tomcat.pid (or other directory of your choice) so you have more control over the Tomcat process.

Then to start Tomcat find catalina.sh in <CATALINA_HOME>/bin and execute:

./catalina.sh start

and to stop it run:

./catalina.sh stop 10 -force

From catalina.sh script's doc:

./catalina.sh

Usage: catalina.sh ( commands ... )
commands:

start             Start Catalina in a separate window
stop              Stop Catalina, waiting up to 5 seconds for the process to end
stop n            Stop Catalina, waiting up to n seconds for the process to end
stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running

Note: If you want to use -force flag then setting CATALINA_PID is mandatory.

Arleanarlee answered 9/11, 2016 at 17:21 Comment(0)
P
4

It seems Tomcat was actually stopped. I started it and it started fine. Thanks all.

Plautus answered 11/9, 2012 at 12:38 Comment(0)
W
3

Recent I have met several times of stop abnormal. Although shutdown.sh provides some information, The situations are:

  • result of the command ps -ef| grep java is Null.
  • result of the command ps -ef| grep java is not null.

My opinion is just kill the process of Catalina and remove the pid file (In your situation is /opt/tomcat/work/catalina.pid.)

The result seems not so seriously to influence others.

Watery answered 9/11, 2015 at 11:1 Comment(0)
L
3

sometimes if the same pid is running after reboot tomcat will not start

my pid file was at apache-tomcat/temp/tomcat.pid

as a solution, I just check if the PID is of Catalina

change file apache-tomcat/bin/catalina.sh about line 386

from ps -p $PID >/dev/null 2>&1

to ps -fp $PID |grep catalina >/dev/null 2>&1

excerpt from catalina.sh file

 if [ ! -z "$CATALINA_PID" ]; then
    if [ -f "$CATALINA_PID" ]; then
      if [ -s "$CATALINA_PID" ]; then
        echo "Existing PID file found during start."
        if [ -r "$CATALINA_PID" ]; then
          PID=`cat "$CATALINA_PID"`
          ps -fp $PID |grep catalina >/dev/null 2>&1  #this line
          if [ $? -eq 0 ] ; then
            echo "Tomcat appears to still be running with PID $PID. Start aborted."
            echo "If the following process is not a Tomcat process, remove the PID file and try again:"
            ps -f -p $PID
            exit 1
          else
            echo "Removing/clearing stale PID file."
            rm -f "$CATALINA_PID" >/dev/null 2>&1
            if [ $? != 0 ]; then
              if [ -w "$CATALINA_PID" ]; then
                cat /dev/null > "$CATALINA_PID"
              else
                echo "Unable to remove or clear stale PID file. Start aborted."
                exit 1
              fi
            fi
          fi
        else
          echo "Unable to read PID file. Start aborted."
Lapidify answered 22/11, 2018 at 13:37 Comment(0)
T
1

You can go to the location ${CATALINA_HOME}/logs/ open catalina.pid. Here we will get the pid. then terminate the process. kill -9 pid

Tadeas answered 20/3, 2015 at 7:41 Comment(0)
L
1

Have you try $ sudo ./catalina.sh stop? It worked in my case.

Larock answered 22/4, 2016 at 7:33 Comment(0)
J
1

FIRST --> rm catalina.engine

THEN -->./startup.sh

NEXT TIME you restart --> ./shutdown.sh -force

Judkins answered 14/7, 2016 at 10:44 Comment(0)
E
1

The catalina.pid is missing in your case.

This file is located under {your_jira_dir}/work/catalina.pid and it contains the pid of the current instance of jira.

so

ps aux | grep jira
  • find the correct entry
  • Copy the PID of the output and create a file that only contains this PID. - Make sure it can be read and written by the user which runs jira.
  • Try to shutdown jira again.
Evin answered 30/3, 2019 at 9:24 Comment(0)
M
1

sudo systemctl stop tomcat

did it for me

Moriyama answered 25/8, 2019 at 1:30 Comment(0)
F
1

Follow this :)

  1. Open : /etc/systemd/system/tomcat.service

Can you see JAVA_HOME ? : modify it like below

Environment="JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64"

At 1.11.0 - insert your own Jdk version

  1. systemctl daemon-reload

  2. sudo systemctl start tomcat


Now, in eclipse -> Add Server -> .....

Got struck at tomcat installation directory ??

  1. Extract the tomcat tar file you already downloaded.
  2. Now go back to eclipse -> add server -> Browse -> Point to extracted file (done in step 1 above :)

Comment if you get struck in somewhere else too )

Fecal answered 21/1, 2021 at 8:38 Comment(0)
A
0

You can always try to kill the process in case you see this kind of issues. You can get the process ID either from PS or from pid file and kill the process.

Ahner answered 25/8, 2015 at 19:30 Comment(0)
A
0

In my case, the tomcat.pid is under /opt/tomcat/temp/. Tried to delete it manually. Still didn't work. After check setnev.sh in /opt/tomcat/bin/, notice there is a line of code to define JAVA_HOME:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre

Commented out this line, restart Tomcat. It works! Since I did a yum update and a new minor version of Java update coming from 1.8.0.212 to 1.8.0.222. Lessons learned: Hard-code should be avoided.

Aquarist answered 8/8, 2019 at 13:22 Comment(0)
B
0

I faced the same problem as mentioned below.

PID file found but no matching process was found. Stop aborted.

Solution is to find the free space of the linux machine by using the following command

df -h

The above command shows my home directory was 100% used. Then identified which files to be removed by using the following command

du -h .

After removing, it was able to perform IO operation on the linux machine and the tomcat was able to start.

Badderlocks answered 12/2, 2020 at 19:5 Comment(0)
L
0

To make sure apache tomcat is not running, you could use following in Linux.

ps -ef | grep tomcat // it will return output if tomcat is up and running

If it is running, use either one of the options to stop tomcat:

./catalina.sh stop

Passing "stop" argument for catalina.sh --> stops the Tomcat in the foreground and displays the running logs in the same console. when the console terminal is closed it will terminate the tomcat.

./shutdown.sh 

This way is firing the shutdown.sh to stop your Tomcat server and finally the last way is using service tomcat stop as below.

sudo service tomcat stop
Lamonicalamont answered 7/5, 2022 at 10:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.