Question

Tomcat not work on CentOs - ExecStop=/bin/kill -15 $MAINPID (code=exited, status=1/FAILURE)

Dear Digital Ocean Community! I can’t run tomcat as service on CentOs. Somebody else encounter with this problem? Please write here.

The error after systemctl status tomcat

● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: dis                                                                                      abled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2019-02-08 07:3                                                                                      7:49 UTC; 1s ago
  Process: 3198 ExecStop=/bin/kill -15 $MAINPID (code=exited, status=1/FAILURE)
  Process: 3185 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCES                                                                                      S)
 Main PID: 3196 (code=exited, status=0/SUCCESS)

Feb 08 07:37:49 centos-s-1vcpu-1gb-ams3-01 systemd[1]: Unit tomcat.service ente...
Feb 08 07:37:49 centos-s-1vcpu-1gb-ams3-01 systemd[1]: tomcat.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

So I think my configuration is good, but anyone think i miss something please write here

Here is my configuration: -1. (If I use tomcat 9.0.14 I have an error message in catalina.out: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appr opriately using -XX:ParallelGCThreads=N

But this I can fix it with change in the 14.point config file(/etc/systemd/system/tomcat.service ) this one: -XX:ParallelGCThreads=N for this: -XX:-AssumeMP Because I use virtual server on Digital Ocean and I have one processor.)

BUT it’s not needed if I use Tomcat 8.5.37

So I use now this step by step…

[root@centos-s-1vcpu-1gb-ams3-01 ~]# java -version openjdk version “1.8.0_191” OpenJDK Runtime Environment (build 1.8.0_191-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

wget http://xenia.sote.hu/ftp/mirrors/www.apache.org/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat-8.5.37.tar.gz 2. tar xzf apache-tomcat-8.5.37.tar.gz 3. mv apache-tomcat-8.5.37/ /opt/tomcat 4. groupadd tomcat 5. useradd -g tomcat -M -d /opt/tomcat -s /bin/nologin tomcat 6. chgrp -R tomcat /opt/tomcat/ 7. chmod -R g+r /opt/tomcat/conf 8. chmod -R g+x /opt/tomcat/conf 9. chown -R tomcat /opt/tomcat/webapps/ 10. chown -R tomcat /opt/tomcat/work/ 11. chown -R tomcat /opt/tomcat/temp/ 12. chown -R tomcat /opt/tomcat/logs/ 13. vi /etc/systemd/system/tomcat.service 14.

Systemd unit file for tomcat

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

[Service] Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/jre 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=/bin/kill -15 $MAINPID

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

[Install] WantedBy=multi-user.target

systemctl daemon-reload 16. systemctl start tomcat 17. systemctl status tomcat


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer