0

I'm hosting a website on a CentOS7 server using Tomcat and Jenkins. It is working and deploying but systemctl says failed and Jenkins says deployments are failing.

$ sudo service tomcat status
Redirecting to /bin/systemctl status tomcat.service
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2019-06-05 22:52:30 EDT; 6s ago
  Process: 1554 ExecStop=/bin/kill -15 $MAINPID (code=exited, status=1/FAILURE)
  Process: 1542 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 1553 (code=exited, status=127)

Jun 05 22:52:30 localhost.localdomain kill[1554]: -q, --queue <sig>      use sigqueue(2) rather than kill(2)
Jun 05 22:52:30 localhost.localdomain kill[1554]: -p, --pid              print pids without signaling them
Jun 05 22:52:30 localhost.localdomain kill[1554]: -l, --list [=<signal>] list signal names, or convert one to a name
Jun 05 22:52:30 localhost.localdomain kill[1554]: -L, --table            list signal names and numbers
Jun 05 22:52:30 localhost.localdomain kill[1554]: -h, --help     display this help and exit
Jun 05 22:52:30 localhost.localdomain kill[1554]: -V, --version  output version information and exit
Jun 05 22:52:30 localhost.localdomain kill[1554]: For more details see kill(1).
Jun 05 22:52:30 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=1
Jun 05 22:52:30 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
Jun 05 22:52:30 localhost.localdomain systemd[1]: tomcat.service failed.

$ sudo /opt/tomcat/startup.sh #doesnt complain 
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Using CATALINA_PID:    /opt/tomcat/catalina_pid.txt
Existing PID file found during start.
Removing/clearing stale PID file.
Tomcat started.

$cat tomcat.service 
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=forking

Environment=JRE_HOME=JAVA_HOME='/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java'
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

Might have similiar problem tomcat works but service tomcat status says it failed

Is kill the issue?

-q, --queue use sigqueue(2) rather than kill(2)

In Jenkins I get this error:

[INFO] Deploying war to http://localhost:80/ROOT  
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Uploading: http://localhost:80/manager/text/deploy?path=%2FROOT&update=true
Uploaded: http://localhost:80/manager/text/deploy?path=%2FROOT&update=true (17848 KB at 57204.3 KB/sec)

[INFO] tomcatManager status code:200, ReasonPhrase:
[INFO] OK - Deployed application at context path [/]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.977s
[INFO] Finished at: Wed Jun 05 23:10:37 EDT 2019
[INFO] Final Memory: 28M/286M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/workspace/WhatThePhil/pom.xml to org.springframework/gs-serving-web-content/0.1.0/gs-serving-web-content-0.1.0.pom
channel stopped
Deploying /var/lib/jenkins/workspace/WhatThePhil/target/gs-serving-web-content-0.1.0.war to container Tomcat 8.x Remote with context 
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/var/lib/jenkins/workspace/WhatThePhil/target/gs-serving-web-content-0.1.0.war]
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:192)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:1078)
    at hudson.FilePath.act(FilePath.java:1061)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1843)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:561)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    ... 17 more
java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:561)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
    at hudson.FilePath.act(FilePath.java:1078)
    at hudson.FilePath.act(FilePath.java:1061)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
    at hudson.model.Run.execute(Run.java:1843)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

I'm not trying to deploy to gs-serving-web-content, which is my artifactId I want it to just deploy to /ROOT and it does.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-serving-web-content</artifactId>
    <version>0.1.0</version>
    <packaging>war</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>http://localhost:80/manager/text</url>
                    <server>TomcatServer</server>
                    <update>true</update>
                    **<path>/ROOT</path>**
                </configuration>
            </plugin>
        </plugins> 
    </build>

</project>

They were passing at one point, but I'd like them always to pass and Tomcat have good status builds were passing at one point EDIT I gave tomcat permission and running as tomcat user:

$ sudo -u tomcat ./startup.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Using CATALINA_PID:    /opt/tomcat/catalina_pid.txt
Existing PID file found during start.
Removing/clearing stale PID file.
Tomcat started.

But status still says failed:

$ sudo -u tomcat systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-06-07 00:14:49 EDT; 22h ago
  Process: 1554 ExecStop=/bin/kill -15 $MAINPID (code=exited, status=1/FAILURE)
  Process: 28058 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=1/FAILURE)
 Main PID: 1553 (code=exited, status=127)

I get this in Catalina.out, but idk if that's just because I started it just now. Or maybe spring boot is trying to deploy outside its container. Everything else looks ok.

 java.net.BindException: Address already in use (Bind failed)

I don't know if this means anything. Builds still failing in Jenkins with the same error.

$ journalctl -xe Jun 07 23:01:01 localhost.localdomain crond[688]: (jenkins) RELOAD (/var/spool/cron/jenkins) Jun 07 23:01:01 localhost.localdomain systemd1: Created slice User Slice of root. -- Subject: Unit user-0.slice has finished start-up -- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- Unit user-0.slice has finished starting up.

-- The start-up result is done. Jun 07 23:01:01 localhost.localdomain systemd1: Starting User Slice of root. -- Subject: Unit user-0.slice has begun start-up -- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- Unit user-0.slice has begun starting up. Jun 07 23:01:01 localhost.localdomain systemd1: Started Session 781 of user root. -- Subject: Unit session-781.scope has finished start-up -- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- Unit session-781.scope has finished starting up.

-- The start-up result is done. Jun 07 23:01:01 localhost.localdomain systemd1: Starting Session 781 of user root. -- Subject: Unit session-781.scope has begun start-up -- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- Unit session-781.scope has begun starting up. Jun 07 23:01:01 localhost.localdomain CROND[2561]: (root) CMD (run-parts /etc/cron.hourly) Jun 07 23:01:01 localhost.localdomain run-parts(/etc/cron.hourly)[2564]: starting 0anacron Jun 07 23:01:01 localhost.localdomain run-parts(/etc/cron.hourly)[2570]: finished 0anacron Jun 07 23:01:01 localhost.localdomain systemd1: Removed slice User Slice of root. -- Subject: Unit user-0.slice has finished shutting down -- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- Unit user-0.slice has finished shutting down. Jun 07 23:01:01 localhost.localdomain systemd1: Stopping User Slice of root. -- Subject: Unit user-0.slice has begun shutting down -- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- Unit user-0.slice has begun shutting down. Jun 07 23:01:19 localhost.localdomain crontab[3711]: (jenkins) LIST (jenkins) Jun 07 23:01:20 localhost.localdomain crontab[4754]: (jenkins) LIST (jenkins) Jun 07 23:01:20 localhost.localdomain crontab[4755]: (jenkins) LIST (jenkins) Jun 07 23:01:22 localhost.localdomain crontab[5162]: (jenkins) LIST (jenkins) Jun 07 23:01:22 localhost.localdomain crontab[5192]: (jenkins) LIST (jenkins) Jun 07 23:01:52 localhost.localdomain crontab[6306]: (jenkins) LIST (jenkins) Jun 07 23:01:54 localhost.localdomain crontab[7090]: (jenkins) LIST (jenkins) Jun 07 23:01:54 localhost.localdomain crontab[7263]: (jenkins) LIST (jenkins) Jun 07 23:01:56 localhost.localdomain crontab[7864]: (jenkins) LIST (jenkins) Jun 07 23:01:57 localhost.localdomain crontab[7907]: (jenkins) LIST (jenkins)

  • Let me know if you need anymore info. I've been stuck on this all week. – Philip Rego Jun 6 at 21:46
0

Your service file shows tomcat starting as the tomcat user, but when you manually run sudo /opt/tomcat/startup.sh it might set permissions on logs, etc, to be root instead of tomcat. Try to run startup.sh as the tomcat user and see if it starts up or throws errors. You might want to chown -R tomcat:tomcat /opt/tomcat and then try the service file again.

Also check the catalina.out log and journalctl -xe file to see if that gives you more info on what failed.

  • I ran your chown command and ran statup as tomcat but systemctl and jenkins still say failed. I updated the info. This is the site. whatthephil.com – Philip Rego Jun 8 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.