Reputation: 790
I'm facing a problem with Apache Tomcat 9.0.50, Ubuntu Server 18.04 LTS and Java JDK 8.
I am not able to start Tomcat9 as a service, because if I check its status after started, it shows the error: PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted.
I've created a dedicated group and user for Tomcat (group tomcat9, user tomcat9).
If I check the ps (process-show) Linux tool, for example with:
ps -faux | grep tomcat
Tomcat is not present, so the process is not active.
I'm running sudo systemctl start tomcat.service
with the "sadmin" account that belongs to sudoers and also belongs to tomcat9 group.
Jul 06 17:14:55 i-s-023 systemd[1]: Starting Tomcat9...
Jul 06 17:14:55 i-s-023 startup.sh[5257]: Existing PID file found during start.
Jul 06 17:14:55 i-s-023 startup.sh[5257]: Removing/clearing stale PID file.
Jul 06 17:14:55 i-s-023 startup.sh[5257]: Tomcat started.
Jul 06 17:14:55 i-s-023 shutdown.sh[5279]: PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted.
Jul 06 17:14:55 i-s-023 systemd[1]: tomcat.service: Control process exited, code=exited status=1
Jul 06 17:14:55 i-s-023 systemd[1]: tomcat.service: Failed with result 'exit-code'.
Jul 06 17:14:55 i-s-023 systemd[1]: Failed to start Tomcat9.
Here it is my /opt folder:
drwxr-xr-x 4 root root 4096 Jul 6 14:44 .
drwxr-xr-x 24 root root 4096 Jun 24 01:26 ..
drwxr-xr-x 9 tomcat9 tomcat9 4096 Jul 6 16:43 apache-tomcat-9.0.50
-rw-r--r-- 1 root root 11507318 Jun 28 10:52 apache-tomcat-9.0.50.tar.gz
drwxr-xr-x 7 root root 4096 Jul 6 16:34 jdk1.8.0_221
lrwxrwxrwx 1 root root 20 Jul 6 14:44 tomcat-latest -> apache-tomcat-9.0.50
Those are permissions inside /opt/tomcat-latest folder
drwxr-xr-x 9 tomcat9 tomcat9 4096 Jul 6 16:43 .
drwxr-xr-x 4 root root 4096 Jul 6 14:44 ..
drwxrwx--- 2 root tomcat9 4096 Jul 6 14:44 bin
-rw-r----- 1 root tomcat9 18949 Jun 28 10:46 BUILDING.txt
drwxr-x--- 2 root tomcat9 4096 Jun 28 10:46 conf
-rw-r----- 1 root tomcat9 6210 Jun 28 10:46 CONTRIBUTING.md
drwxr-x--- 2 root tomcat9 4096 Jul 6 14:44 lib
-rw-r----- 1 root tomcat9 57092 Jun 28 10:46 LICENSE
drwxr-x--- 2 tomcat9 tomcat9 4096 Jul 6 14:46 logs
-rw-r----- 1 root tomcat9 2333 Jun 28 10:46 NOTICE
-rw-r----- 1 root tomcat9 3372 Jun 28 10:46 README.md
-rw-r----- 1 root tomcat9 6898 Jun 28 10:46 RELEASE-NOTES
-rw-r----- 1 root tomcat9 16507 Jun 28 10:46 RUNNING.txt
drwxr-x--- 2 tomcat9 tomcat9 4096 Jul 6 17:14 temp
drwxr-x--- 7 tomcat9 tomcat9 4096 Jun 28 10:46 webapps
drwxr-x--- 2 tomcat9 tomcat9 4096 Jun 28 10:46 work
The service is defined as shown below:
[Unit]
Description=Tomcat9
After=network.target
[Service]
Type=forking
User=tomcat9
Group=tomcat9
WorkingDirectory=/opt/tomcat-latest/bin
Environment=CATALINA_PID=/opt/tomcat-latest/temp/tomcat9.pid
Environment=JAVA_HOME=/opt/jdk1.8.0_221
Environment=CATALINA_HOME=/opt/tomcat-latest
Environment=CATALINA_BASE=/opt/tomcat-latest
Environment="CATALINA_OPTS=-Xms1280m -Xmx3840m"
Environment="JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -Dorg.apache.tomcat.util.buf.UDec$
ExecStart=/opt/tomcat-latest/bin/startup.sh
ExecStop=/opt/tomcat-latest/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
Do you have any advice? Thanks in advance
Upvotes: 3
Views: 17136
Reputation: 330
I encountered this error message, while addressing a Java installation that was installed using sdkman and was installed under /root
, hence being not accessible for the tomcat
user.
I solved it by installing sdkman as user tomcat
and then installing the same Java version in a directory that was accessible by tomcat
. Last, I changed the path in my service file, of course.
Upvotes: 0
Reputation: 1
I have the same issue with permission granted, java installed, JAVA_HOME correctly configured.
Solved it by adding a "" at the ExecStart and ExecStop path
ExecStart="/opt/tomcat-latest/bin/startup.sh"
ExecStop="/opt/tomcat-latest/bin/shutdown.sh"
Upvotes: 0
Reputation: 11
I had a same issue short time ago.My problem was systemd unit file was addressing wrong arch java.Changed JAVA_HOME and fixed.
Upvotes: 1
Reputation: 3395
Ensure that the Environment points to existing path. In my case JAVA_HOME was set to non existent java.
Upvotes: 1