Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATALINA_PID was set but the specified file does not exist

I was following this guide to setup tomcat on Ubuntu 16.04.2 LTS Xenial (https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04).

Got to the point of the first launch:

sudo systemctl start tomcat

and received an error:

~$ sudo systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.

journalctl -xe
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit tomcat.service has begun starting up.
Feb 27 15:23:42 76672.local startup.sh[20551]: Tomcat started.
Feb 27 15:23:42 76672.local shutdown.sh[20563]: $CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.
Feb 27 15:23:42 76672.local systemd[1]: tomcat.service: Control process exited, code=exited status=1
Feb 27 15:23:42 76672.local systemd[1]: Failed to start Tomcat 9 servlet container.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit tomcat.service has failed.
-- 
-- The result is failed.

CATALINA_PID expected to be in a directory /opt/tomcat/latest/temp/tomcat.pid

I gave rights to do everyone for everything for this dir /opt/tomcat and all subfolders/files:

~$ namei -l /opt/tomcat
f: /opt/tomcat
drwxr-xr-x root   root   /
drwxr-xr-x root   root   opt
drwxrwxrwx tomcat tomcat tomcat

Does anyone can point me to the possible solutions?

UPD: Using bin/startup.sh Tomcat successfully starts.

like image 830
Maxim Andreev Avatar asked Jan 27 '26 21:01

Maxim Andreev


1 Answers

When you use CATALINA_PID in tomcat.service file please make sure to use the path inside of the double-quotes.

Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid" 

Like below


[Unit]
Description=Tomcat 9 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"

Environment="CATALINA_BASE=/opt/tomcat/"
Environment="CATALINA_HOME=/opt/tomcat/"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

congratulations!

like image 147
Mafei Avatar answered Jan 31 '26 10:01

Mafei