title: How to resolve tomcat Failed with result exit-code issue in ubuntu server?
body: <p>when I check my tomcat status it occur error. How to resolve this issue in ubuntu server?</p>
  
  <blockquote>
    <p>sudo systemctl status tomcat</p>
  </blockquote>
  
  <pre><code>tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2018-03-22 05:53:07 UTC; 1h 32min ago
   Main PID: 20422 (java)
      Tasks: 21
     Memory: 1.0G
        CPU: 36.353s
     CGroup: /system.slice/tomcat.service
         └─20422 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.m
  
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: Stopped Apache Tomcat Web Application Container.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: tomcat.service: Unit entered failed state.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: tomcat.service: Failed with result 'exit-code'.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: Starting Apache Tomcat Web Application Container...
  Mar 22 05:53:07 ip-172-31-41-119 startup.sh[20410]: export JAVA_OPTS -Djava.awt.headless=true -server -Xms500m -Xmx1536M -XX:MaxPermSize=512m
  Mar 22 05:53:07 ip-172-31-41-119 startup.sh[20410]: Tomcat started.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: Started Apache Tomcat Web Application Container.
  Mar 22 06:01:53 ip-172-31-41-119 systemd[1]: Started Apache Tomcat Web Application Container.
  ...skipping...
  ● tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2018-03-22 05:53:07 UTC; 1h 32min ago
   Main PID: 20422 (java)
      Tasks: 21
     Memory: 1.0G
        CPU: 36.353s
     CGroup: /system.slice/tomcat.service
         └─20422 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.m
  
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: Stopped Apache Tomcat Web Application Container.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: tomcat.service: Unit entered failed state.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: tomcat.service: Failed with result 'exit-code'.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: Starting Apache Tomcat Web Application Container...
  Mar 22 05:53:07 ip-172-31-41-119 startup.sh[20410]: export JAVA_OPTS -Djava.awt.headless=true -server -Xms500m -Xmx1536M -XX:MaxPermSize=512m
  Mar 22 05:53:07 ip-172-31-41-119 startup.sh[20410]: Tomcat started.
  Mar 22 05:53:07 ip-172-31-41-119 systemd[1]: Started Apache Tomcat Web Application Container.
  Mar 22 06:01:53 ip-172-31-41-119 systemd[1]: Started Apache Tomcat Web Application Container.
  </code></pre>
  
  <p><strong>apache.service</strong> file</p>
  
  <pre><code>[Unit]
  Description=Apache Tomcat Web Application Container
  After=network.target
  
  [Service]
  Type=forking
  
  Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/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=/opt/tomcat/bin/shutdown.sh
  
  User=root
  Group=root
  UMask=0007
  RestartSec=10
  Restart=always
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <blockquote>
    <p>ERROR DruidDataSource:2453 - create connection SQLException, url: jdbc:mysql://xx.xx.xx.xx:3306/mydb?autoReconnect=true&amp;useSSL=false&amp;useUnicode=yes&amp;characterEncoding=UTF-8, errorCode 0, state 08001
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)</p>
  </blockquote>