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

3

Simply delete everything you have done so far. Then:

sudo apt-get install tomcat8
sudo service tomcat8 start
  • Can you give more details? – yass Apr 5 '17 at 16:50
  • apt-get is the package manager for ubuntu. The first command installs ubuntu, the second command starts it. The error the OP was getting is based on trying to install Tomcat manually. – Lisandro Apr 5 '17 at 17:46
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).

  • Nice touch downvoting it without an explanation. Would really like to know why. As stated in my answer I followed the same procedure the OP did. Got the same error. So the downvote should really go to that article :) And told him how he should have installed it :) – Zina May 15 '18 at 20:34
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
0

You have to exec

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

Tomcat needs to start catalina.sh from startup.sh

  • Adding more context to this answer by editing it, would make this much more useful to anyone who may come across this in the future. – Worthwelle Oct 30 '18 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.