A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8

Overview

I solved the problem once, but I encountered the same problem again in another environment and did not keep a record, so I struggled for 2 hours and made a note not to repeat the third mistake in the future.

environment

If it doesn't work

If I create /etc/systemd/system/tomcat.service as in the example at (https://weblabo.oscasierra.net/installing-tomcat8-centos7-1/), it doesn't work.

File Edit Options Buffers Tools Help
[Unit]
Description=Apache Tomcat 8
After=network.target

[Service]
User=tomcat
Group=tomcat
Type=oneshot
PIDFile=/usr/java/tomcat8/temp/tomcat.pid
RemainAfterExit=yes

ExecStart=/usr/java/tomcat8/bin/startup.sh
ExecStop=/usr/java/tomcat8/bin/shutdown.sh
ExecReStart=/usr/java/tomcat8/bin/shutdown.sh;/usr/java/tomcat8/bin/startup.sh

[Install]
WantedBy=multi-user.target

Error if it doesn't work

By the way, if you run /usr/java/tomcat8/bin/startup.sh manually, it works fine.

[root@localhost ~]# systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.

August 11 23:47:39 localhost.localdomain systemd[1]: Starting Apache Tomcat 8...
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit tomcat.service has begun starting up.
August 11 23:47:39 localhost.localdomain systemd[2079]: tomcat.service: Failed to execute command: Permission denied
August 11 23:47:39 localhost.localdomain systemd[2079]: tomcat.service: Failed at step EXEC spawning /usr/java/tomcat8/bin/startup.sh: Permission denied
-- Subject: Process /usr/java/tomcat8/bin/startup.sh could not be executed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The process /usr/java/tomcat8/bin/startup.sh could not be executed and failed.
--
-- The error number returned by this process is 13.
August 11 23:47:39 localhost.localdomain systemd[1]: tomcat.service: Main process exited, code=exited, status=203/EXEC
August 11 23:47:39 localhost.localdomain systemd[1]: tomcat.service: Failed with result 'exit-code'.
August 11 23:47:39 localhost.localdomain systemd[1]: Failed to start Apache Tomcat 8.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit tomcat.service has failed.
--
-- The result is failed.

If it works

You may want to refer to https://stackoverflow.com/questions/53994521/tomcat-8-on-centos-7-does-not-start-as-service-but-it-starts-manually.

The setting that finally worked. As mentioned in the URL above, is the Working Directory suspicious after all?

/etc/systemd/system/tomcat.service


[Unit]
Description=Apache Tomcat 8
After=network.target

[Service]
Type=forking
WorkingDirectory=/usr/java/tomcat8/bin

ExecStart=/bin/bash /usr/java/tomcat8/bin/catalina.sh start
ExecStop=/bin/bash /usr/java/tomcat8/bin/catalina.sh stop

User=tomcat
Group=tomcat

[Install]
WantedBy=multi-user.target

Recommended Posts

A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
I was addicted to the setting of laradock + VSCode + xdebug
The story I was addicted to when setting up STS
A memorandum because I was addicted to the setting of the Android project of IntelliJ IDEA
A story I was addicted to when getting a key that was automatically tried on MyBatis
I was addicted to the API version min23 setting of registerTorchCallback
A story I was addicted to with implicit type conversion of ActiveRecord during unit testing
A memo that was soberly addicted to the request of multipart / form-data
A story I was addicted to when testing the API using MockMVC
[CircleCI] I was addicted to the automatic test of CircleCI (rails + mysql) [Memo]
The story of making it possible to build a project that was built by Maven with Ant
A story that I wanted to write a process equivalent to a while statement with the Stream API of Java8
I was addicted to the record of the associated model
A memo that I was addicted to when making batch processing with Spring Boot
A story that I had a hard time trying to build PHP 7.4 on GCE's CentOS 8
I was addicted to setting default_url_options with Rails devise introduction
I was addicted to looping the Update statement on MyBatis
A story I was addicted to in Rails validation settings
A story addicted to toString () of Interface proxied with JdkDynamicAopProxy
What I was addicted to with the Redmine REST API
[Circle CI] A story I was addicted to at Start Building
A story that I struggled to challenge a competition professional with Java
The story of Collectors.groupingBy that I want to keep for posterity
A story of connecting to a CentOS 8 server with an old Ansible
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
About the matter that I was addicted to how to use hashmap
A story that struggled with the introduction of Web Apple Pay
Technical causes and countermeasures for the points that I was addicted to with the Android app & Kotlin (2. Processing related to the camera function of Android *)
I was addicted to the roll method
I was addicted to the Spring-Batch test
The story of making a game launcher with automatic loading function [Java]
I was addicted to a simple test of Jedis (Java-> Redis library)
Problems I was addicted to when building the digdag environment with docker
Recorded because I was addicted to the standard input of the Scanner class
I was addicted to unit testing with the buffer operator in RxJava
A story that was embarrassing to give anison file to the production environment
I was addicted to using RXTX on Sierra
A story addicted to EntityNotFoundException of getOne of JpaRepository
I was addicted to installing Ruby/Tk on MacOS
I was addicted to doing onActivityResult () with DialogFragment
I was a little addicted to the S3 Checksum comparison, so I made a note.
SpringSecurity I was addicted to trying to log in with a hashed password (solved)
A story that I was really into when I did triple DES with ruby
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC
I want you to put the story that the error was solved when you stabbed the charger in the corner of your head
A story that people who did iOS solidly may be addicted to the implementation of Listener when moving to Android
[Ruby] I want to make a program that displays today's day of the week!
What I was addicted to when developing a Spring Boot application with VS Code
The story that did not disappear when I tried to delete mysql on ubuntu
The CSV file that I was able to download suddenly started to appear on the page.
[Spring Boot] The story that the bean of the class with ConfigurationProperties annotation was not found
The part I was addicted to in "Introduction to Ajax in Java Web Applications" of NetBeans
[Java] The problem that true was returned as a result of comparing Integer with ==
I was addicted to the NoSuchMethodError in Cloud Endpoints
The story of making a reverse proxy with ProxyServlet
Addicted to the webpacker that comes standard with Rails 6
kintone clone? I was quite addicted to launching OSS WebDB Extension with Lightsail + Docker, so make a note of it.
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
A note that I had trouble when trying to use nginx with Remote-Containers of vscode
A story I was addicted to before building a Ruby and Rails environment using Ubuntu (20.04.1 LTS)
When I personally developed with Rails, it was a painful story that Rails was hit very much