6

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

5 Answers5

5

Simply delete everything you have done so far. Then:

sudo apt-get install tomcat8
sudo service tomcat8 start
Lisandro
  • 151
1

You have to exec

cd /opt/tomcat/bin && sudo chmod +x catalina.sh

Tomcat needs to start catalina.sh from startup.sh

cdarwin
  • 121
1

The best way to find the answer is to change your tomcat-user to be able to login and see what happens when the "startup.sh" is being run. Simply change /etc/passwd like this (notice a bash-shell as the last column):

tomcat:x:1001:1001::/home/tomcat:/bin/bash

Then login by running

sudo su - tomcat

Then run the

./startup.sh

It will display the real reason why the command failed.

mortensi
  • 111
0

Followed the article and got the same error as you.

After a:

chgrp -R tomcat bin chmod g+rwx bin chmod g+r bin/*

it worked for me.

No need to change all files/folders in /opt/tomcat (only the startup, shutdown and the ones invoked by those two - that's why I used the whole bin folder).

BTW, you could also make a apt-get install tomcat8 to get a working tomcat8 server :) (this creates a tomcat8 user/group with an ID below 1000).

Zina
  • 2,327
0

In Centos 7.4 I tried all of the paths but can't find the solution. At last I started tomcat directly.

chmod +x /opt/tomcat/bin/*.sh
ln -s /opt/tomcat/bin/startup.sh /usr/bin/tomcatstart
ln -s /opt/tomcat/bin/shutdown.sh /usr/bin/tomcatshutdown
tomcatstart

Linked these executable files to /usr/bin and I can start it in everywhere. Put the code "tomcatstart" to /etc/environment and tomcat starts on boot. My current environment file is:

export JAVA_HOME=/opt/jdk1.8.0_144
export JRE_HOME=/opt/jdk1.8.0_144/jre
export PATH=$PATH:/opt/jdk1.8.0_144/bin:/opt/jdk1.8.0_144/jre/bin
tomcatstart