By milan7
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…
0.
[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)
1.
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
15.
systemctl daemon-reload
16.
systemctl start tomcat
17.
systemctl status tomcat
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!
Hello,
Based on the information provided, it appears that your Tomcat service configuration and setup are mostly correct. However, the issue might be related to the Type=forking setting in the tomcat.service file.
Change the Type in the [Service] section: Update the Type from forking to simple:
Update the ExecStart and ExecStop commands: Replace the startup.sh script in the ExecStart line with catalina.sh and remove the ExecStop line:
- ExecStart=/opt/tomcat/bin/catalina.sh run
Remove the ExecStop command
- ExecStop=/bin/kill -15 $MAINPID
sudo systemctl daemon-reload
sudo systemctl restart tomcat
sudo systemctl status tomcat
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.