title: Tomcat 8 on CentOS 7 does not start as service (but it starts manually ....)
body: <p>I've installed Tomcat (apache-tomcat-8.5.37), on a CentOS VM (using bento/centos-7).</p>
  
  <p>Tomcat is installed in </p>
  
  <pre><code>/opt/tomcat/apache-tomcat-8.5.37
  </code></pre>
  
  <p>and Java 8 is installed in </p>
  
  <pre><code>/usr/java/jre1.8.0_192-amd64
  </code></pre>
  
  <p>Before to install Tomcat I've created a <code>tomcat</code> user in this way</p>
  
  <pre><code>sudo useradd tomcat
  sudo passwd tomcat
  sudo mkdir /opt/tomcat
  sudo chown -R tomcat:tomcat /opt/tomcat
  su – tomcat
  </code></pre>
  
  <p>If I try to start Tomcat manually using </p>
  
  <pre><code>/opt/tomcat/apache-tomcat-8.5.37/bin/startup.sh
  </code></pre>
  
  <p>all works fine and I can test Tomcat ad its examples from the url</p>
  
  <pre><code>http://192.168.33.10:8080
  </code></pre>
  
  <p>(note: 192.168.33.10 is the IP of my virtual machine ...)</p>
  
  <p>I can also shutdown Tomcat using </p>
  
  <pre><code>/opt/tomcat/apache-tomcat-8.5.37/bin/shutdown.sh
  </code></pre>
  
  <p>I'd like to start Tomcat like e service so I've stopped Tomcat and then  I've edited a file</p>
  
  <pre><code>/etc/systemd/system/tomcat.service
  </code></pre>
  
  <p>with this content</p>
  
  <pre><code>[Unit]
  Description=Apache Tomcat Web Application Container
  After=syslog.target network.target
  
  [Service]
  Type=forking
  
  Environment=JAVA_HOME=/usr/java/jre1.8.0_192-amd64
  Environment=CATALINA_PID=/opt/tomcat/apache-tomcat-8.5.37/temp/tomcat.pid
  Environment=CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.37/
  Environment=CATALINA_BASE=/opt/tomcat/apache-tomcat-8.5.37/
  Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
  Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
  
  ExecStart=/opt/tomcat/apache-tomcat-8.5.37/bin/startup.sh
  ExecStop=/bin/kill -15 $MAINPID
  
  User=tomcat
  Group=tomcat
  UMask=0007
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>sudo systemctl daemon-reload
  </code></pre>
  
  <p>and </p>
  
  <pre><code>sudo systemctl start tomcat
  </code></pre>
  
  <p>Tomcat does not responding now invoking the url</p>
  
  <pre><code>http://192.168.33.10:8080
  </code></pre>
  
  <p>and the output of </p>
  
  <pre><code>sudo systemctl status tomcat
  </code></pre>
  
  <p>is the follow</p>
  
  <pre><code>● tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Tue 2019-01-01 09:34:46 UTC; 13min ago
    Process: 14438 ExecStop=/bin/kill -15 $MAINPID (code=exited, status=1/FAILURE)
    Process: 14425 ExecStart=/opt/tomcat/apache-tomcat-8.5.37/bin/startup.sh (code=exited, status=0/SUCCESS)
   Main PID: 14436 (code=exited, status=0/SUCCESS)
  
  Jan 01 09:34:46 localhost.localdomain systemd[1]: Starting Apache Tomcat Web Application Container...
  Jan 01 09:34:46 localhost.localdomain startup.sh[14425]: Existing PID file found during start.
  Jan 01 09:34:46 localhost.localdomain startup.sh[14425]: Removing/clearing stale PID file.
  Jan 01 09:34:46 localhost.localdomain systemd[1]: Started Apache Tomcat Web Application Container.
  Jan 01 09:34:46 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=1
  Jan 01 09:34:46 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
  Jan 01 09:34:46 localhost.localdomain systemd[1]: tomcat.service failed.
  </code></pre>
  
  <p>The output of </p>
  
  <pre><code>journalctl -xe
  </code></pre>
  
  <p>is the follow</p>
  
  <pre><code>Jan 01 09:34:46 localhost.localdomain sudo[14418]:   tomcat : TTY=pts/0 ; PWD=/opt/tomcat/apache-tomcat-8.5.37/temp ; USER=root ; COMMAND=/bin/systemctl start tomcat
  Jan 01 09:34:46 localhost.localdomain polkitd[635]: Registered Authentication Agent for unix-process:14419:1135902 (system bus name :1.85 [/usr/bin/pkttyagent --notify-fd 5 --fallb
  Jan 01 09:34:46 localhost.localdomain systemd[1]: Starting Apache Tomcat Web Application Container...
  -- Subject: Unit tomcat.service has begun start-up
  -- Defined-By: systemd
  -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  --
  -- Unit tomcat.service has begun starting up.
  Jan 01 09:34:46 localhost.localdomain startup.sh[14425]: Existing PID file found during start.
  Jan 01 09:34:46 localhost.localdomain startup.sh[14425]: Removing/clearing stale PID file.
  Jan 01 09:34:46 localhost.localdomain startup.sh[14425]: Tomcat started.
  Jan 01 09:34:46 localhost.localdomain polkitd[635]: Unregistered Authentication Agent for unix-process:14419:1135902 (system bus name :1.85, object path /org/freedesktop/PolicyKit1
  Jan 01 09:34:46 localhost.localdomain systemd[1]: Started Apache Tomcat Web Application Container.
  -- Subject: Unit tomcat.service has finished start-up
  -- Defined-By: systemd
  -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  --
  -- Unit tomcat.service has finished starting up.
  --
  -- The start-up result is done.
  Jan 01 09:34:46 localhost.localdomain kill[14438]: Usage:
  Jan 01 09:34:46 localhost.localdomain kill[14438]: kill [options] &lt;pid|name&gt; [...]
  Jan 01 09:34:46 localhost.localdomain kill[14438]: Options:
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -a, --all              do not restrict the name-to-pid conversion to processes
  Jan 01 09:34:46 localhost.localdomain kill[14438]: with the same uid as the present process
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -s, --signal &lt;sig&gt;     send specified signal
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -q, --queue &lt;sig&gt;      use sigqueue(2) rather than kill(2)
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -p, --pid              print pids without signaling them
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -l, --list [=&lt;signal&gt;] list signal names, or convert one to a name
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -L, --table            list signal names and numbers
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -h, --help     display this help and exit
  Jan 01 09:34:46 localhost.localdomain kill[14438]: -V, --version  output version information and exit
  Jan 01 09:34:46 localhost.localdomain kill[14438]: For more details see kill(1).
  Jan 01 09:34:46 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=1
  Jan 01 09:34:46 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
  Jan 01 09:34:46 localhost.localdomain systemd[1]: tomcat.service failed.
  Jan 01 09:34:59 localhost.localdomain sudo[14451]:   tomcat : TTY=pts/0 ; PWD=/opt/tomcat/apache-tomcat-8.5.37/temp ; USER=root ; COMMAND=/bin/systemctl status tomcat
  Jan 01 09:48:45 localhost.localdomain sudo[15115]:   tomcat : TTY=pts/0 ; PWD=/opt/tomcat/apache-tomcat-8.5.37/bin ; USER=root ; COMMAND=/bin/systemctl status tomcat
  </code></pre>
  
  <p>The output of catalina.out is the follow</p>
  
  <pre><code>01-Jan-2019 09:09:21.585 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
  01-Jan-2019 09:09:21.602 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
  01-Jan-2019 09:09:21.614 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2829 ms
  01-Jan-2019 09:09:21.697 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
  01-Jan-2019 09:09:21.697 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.37
  01-Jan-2019 09:09:21.738 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/ROOT]
  01-Jan-2019 09:09:22.777 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/ROOT] has finished in [1,038] ms
  01-Jan-2019 09:09:22.795 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/docs]
  01-Jan-2019 09:09:22.847 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/docs] has finished in [70] ms
  01-Jan-2019 09:09:22.847 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/examples]
  01-Jan-2019 09:09:23.468 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/examples] has finished in [621] ms
  01-Jan-2019 09:09:23.469 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/host-manager]
  01-Jan-2019 09:09:23.522 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/host-manager] has finished in [54] ms
  01-Jan-2019 09:09:23.522 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/manager]
  01-Jan-2019 09:09:23.569 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/tomcat/apache-tomcat-8.5.37/webapps/manager] has finished in [47] ms
  01-Jan-2019 09:09:23.592 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
  01-Jan-2019 09:09:23.601 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
  01-Jan-2019 09:09:23.604 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1990 ms
  01-Jan-2019 09:12:38.830 INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
  01-Jan-2019 09:12:38.831 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
  01-Jan-2019 09:12:38.870 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
  01-Jan-2019 09:12:38.878 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
  01-Jan-2019 09:12:39.117 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
  01-Jan-2019 09:12:39.123 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
  01-Jan-2019 09:12:39.131 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
  01-Jan-2019 09:12:39.137 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
  </code></pre>
  
  <p>????</p>
  
  <p>Suggestions are appreciated!!</p>