title: Tomcat: Can't start tomcat after installing it on Ubuntu: "Job for tomcat.service failed because the control process exited with error code."
body: <p>I followed the steps <a href="https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04" rel="noreferrer">https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04</a> to install <a href="http://apache.cs.utah.edu/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz" rel="noreferrer">tomcat 8.5.24</a> on Ubuntu 16.04, till running <code>sudo ufw allow 8080</code> in "Step 6: Adjust the Firewall and Test the Tomcat Server".</p>
  
  <p>Then I can't start tomcat, </p>
  
  <pre><code>$ sudo 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.
  </code></pre>
  
  <p>and the link <code>http://localhost:8080/</code> doesn't work in both firefox and google chrome browsers. </p>
  
  <p>I was wondering how to solve the problem.</p>
  
  <p>The following details are what I followed the above output messages of <code>sudo systemctl start tomcat</code>. It seems that <code>/opt/tomcat/bin/startup.sh</code> succeeded while <code>/opt/tomcat/bin/shutdown.sh</code> failed. Much appreciate your help!</p>
  
  <pre><code>$ systemctl status tomcat.service
  ● tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2017-12-01 18:55:30 EST; 2s ago
    Process: 19490 ExecStop=/opt/tomcat/bin/shutdown.sh (code=exited, status=1/FAILURE)
    Process: 19478 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
   Main PID: 19440 (code=exited, status=127)
  
  Dec 01 18:55:30 ocean systemd[1]: tomcat.service: Control process exited, code=exited status=1
  Dec 01 18:55:30 ocean systemd[1]: Failed to start Apache Tomcat Web Application Container.
  Dec 01 18:55:30 ocean systemd[1]: tomcat.service: Unit entered failed state.
  Dec 01 18:55:30 ocean systemd[1]: tomcat.service: Failed with result 'exit-code'.
  
  $ journalctl -xe
  
  -- Unit tomcat.service has begun starting up.
  Dec 01 18:51:24 ocean startup.sh[18873]: Existing PID file found during start.
  Dec 01 18:51:24 ocean startup.sh[18873]: Removing/clearing stale PID file.
  Dec 01 18:51:24 ocean startup.sh[18873]: Tomcat started.
  Dec 01 18:51:24 ocean shutdown.sh[18885]: PID file found but no matching process was found. Stop aborted.
  Dec 01 18:51:24 ocean systemd[1]: tomcat.service: Control process exited, code=exited status=1
  Dec 01 18:51:24 ocean 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.
  Dec 01 18:51:24 ocean systemd[1]: tomcat.service: Unit entered failed state.
  Dec 01 18:51:24 ocean systemd[1]: tomcat.service: Failed with result 'exit-code'.
  Dec 01 18:51:34 ocean systemd[1]: tomcat.service: Service hold-off time over, scheduling restart.
  Dec 01 18:51:34 ocean systemd[1]: Stopped Apache Tomcat Web Application Container.
  -- Subject: Unit tomcat.service has finished shutting down
  -- Defined-By: systemd
  -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  -- 
  -- Unit tomcat.service has finished shutting down.
  Dec 01 18:51:34 ocean 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.
  Dec 01 18:51:35 ocean startup.sh[18896]: Existing PID file found during start.
  Dec 01 18:51:35 ocean startup.sh[18896]: Removing/clearing stale PID file.
  Dec 01 18:51:35 ocean startup.sh[18896]: Tomcat started.
  Dec 01 18:51:35 ocean shutdown.sh[18908]: PID file found but no matching process was found. Stop aborted.
  Dec 01 18:51:35 ocean systemd[1]: tomcat.service: Control process exited, code=exited status=1
  Dec 01 18:51:35 ocean 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.
  Dec 01 18:51:35 ocean systemd[1]: tomcat.service: Unit entered failed state.
  Dec 01 18:51:35 ocean systemd[1]: tomcat.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p>My Java versions are</p>
  
  <pre><code>$ java --version
  java 9.0.1
  Java(TM) SE Runtime Environment (build 9.0.1+11)
  Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
  
  $ javac --version
  javac 9.0.1
  </code></pre>
  
  <hr>
  
  <p><strong>update:</strong></p>
  
  <p>Instead of <code>sudo systemctl start tomcat</code> which gives the error above, if I run</p>
  
  <pre><code>cd /opt/tomcat/bin
  
  sudo ./catalina.sh run
  </code></pre>
  
  <p><a href="http://localhost:8080/" rel="noreferrer">http://localhost:8080/</a> shows the correct webpage. SO what is the reason that one doesn't work while the other does?</p>