Ubuntu – Permissions for tomcat 8 service file not working

systemdtomcatUbuntu

I'm trying to install tomcat 8 on ubuntu 16.04. This is the guide I'm following:

https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04

The basic idea is that you're supposed to create an additional user named "tomcat" with limited rights to run tomcat. When I try to run the final command to start as a service (tried it as root):

sudo systemctl start tomcat

I get the following error:

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

Checking systemctl status:

tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) 
Process: 14 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=203/EXEC)

systemd[1]: Starting Apache Tomcat Web Application Container...
systemd[1]: tomcat.service: Control process exited, code=exited status=203
systemd[1]: Failed to start Apache Tomcat Web Application Container.
systemd[1]: tomcat.service: Unit entered failed state.
systemd[1]: tomcat.service: Failed with result 'exit-code'.

This is the tomcat.service file:

# /etc/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

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

User=tomcat
Group=tomcat
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

These are the access rights on the /tomcat/bin folder:

-rwxr-x--- 1 root root   1902 Jul  6 08:44 shutdown.sh
-rwxr-x--- 1 root root   1904 Jul  6 08:44 startup.sh
... 

Other users are reporting the same problem, and suggest giving the "tomcat" user ownership of the entire "tomcat" folder. But that seems to conflict with the spirit of the article (limiting access to improve security).

I'm not sure if I'm missing something implied in the article here regarding permissions?

Thanks

Best Answer

Simply delete everything you have done so far. Then:

sudo apt-get install tomcat8
sudo service tomcat8 start
Related Question