Linux – CentOs 7.1 – Install Tomcat 8

centoslinuxtomcat

I am using this tutorial as a setup reference to getting a Tomcat 8 running on CentOs 7.1, but after typing:

[root@localhost tomcat]# sudo systemctl start tomcat

I get the error:

Job for tomcat.service failed. See 'systemctl status tomcat.service' and 'journalctl -xn' for details.

systemctl status tomcat.service prints the following:

[root@localhost tomcat]# systemctl status tomcat.service
tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled)
Active: failed (Result: exit-code) since Wed 2015-11-25 16:54:33 CET; 1min 19s ago
Process: 45873 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=203/EXEC)

Nov 25 16:54:33 localhost.localdomain systemd[1]: Starting Apache Tomcat Web Application Container...
Nov 25 16:54:33 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=203
Nov 25 16:54:33 localhost.localdomain systemd[1]: Failed to start Apache Tomcat Web Application Container.
Nov 25 16:54:33 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.

journalctl -xn prints the following:

[root@localhost tomcat]# journalctl -xn
-- Logs begin at Wed 2015-11-25 13:50:17 CET, end at Wed 2015-11-25 16:54:33 CET. --
Nov 25 16:50:41 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
-- Subject: Unit postgresql.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has begun starting up.
Nov 25 16:50:42 localhost.localdomain systemd[1]: Started PostgreSQL database server.
-- Subject: Unit postgresql.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has finished starting up.
--
-- The start-up result is done.
Nov 25 16:50:58 localhost.localdomain sshd[39118]: pam_unix(sshd:session): session closed for user demo01
Nov 25 16:50:58 localhost.localdomain systemd-logind[631]: Removed session 44.
-- Subject: A session 44 has been terminated
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A session with the ID 44 has been terminated.
Nov 25 16:54:33 localhost.localdomain sudo[45870]: root : TTY=pts/7 ; PWD=/opt/tomcat ; USER=root ; COMMAND=/bin/systemctl star
Nov 25 16:54:33 localhost.localdomain systemd[1]: Starting Apache Tomcat Web Application Container...
-- Subject: Unit tomcat.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has begun starting up.
Nov 25 16:54:33 localhost.localdomain systemd[45873]: Failed at step EXEC spawning /opt/tomcat/bin/startup.sh: Permission denie
-- Subject: Process /opt/tomcat/bin/startup.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /opt/tomcat/bin/startup.sh could not be executed and failed.
--
-- The error number returned while executing this process is 13.
Nov 25 16:54:33 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=203
Nov 25 16:54:33 localhost.localdomain systemd[1]: Failed to start Apache Tomcat Web Application 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.
Nov 25 16:54:33 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.

What does the error mean and how can i get Tomcat 8 running on my CentOs 7.1 Server?

Best Answer

I've just replied here that I had the same problem and fixed it by:

  1. giving tomcat user ownership of the whole tomcat directory:

    cd /opt && sudo chown -R tomcat tomcat/
    
  2. and commenting out below line in /etc/systemd/system/tomcat.service:

    Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
    

Hope it helps.

Related Question