Maven Cargo Plugin Multiple Executions: Username and Password are Mandatory

306 views Asked by At

I am trying to use the Cargo plugin to deploy to a simple Tomcat clustered environment, with two Tomcat nodes:

  • tomcat1 (192.168.10.21)
  • tomcat2 (192.168.10.22)

When attempting to run mvn cargo:deploy I get the following error:

[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven3-plugin:1.9.4:deploy
 (default-cli) on project sample: Execution default-cli of goal 
org.codehaus.cargo:cargo-maven3-plugin:1.9.4:deploy failed: The 
[cargo.remote.username] and [cargo.remote.password] properties are 
mandatory and need to be defined in your configuration. -> [Help 1]

I have specified the username and password in both executions with no luck. The <build> section of my pom.xml is below. Can anyone assist?

Edit: Provided entire POM.xml instead of just build section.

<?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>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.0</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <groupId>org.jason</groupId>
  <artifactId>sample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>sample</name>
  <packaging>war</packaging>
  <description>Sample Project for Testing Cluster Setup</description>

  <properties>
    <java.version>11</java.version>
    <cargo.remote.username>jason</cargo.remote.username>
    <cargo.remote.password>password</cargo.remote.password>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>

<!--    <dependency>-->
<!--      <groupId>org.springframework.boot</groupId>-->
<!--      <artifactId>spring-boot-starter-test</artifactId>-->
<!--      <scope>test</scope>-->
<!--    </dependency>-->
<!--    <dependency>-->
<!--      <groupId>org.springframework.security</groupId>-->
<!--      <artifactId>spring-security-test</artifactId>-->
<!--      <scope>test</scope>-->
<!--    </dependency>-->
  </dependencies>

  <build>
      <finalName>sample</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven3-plugin</artifactId>
        <version>1.9.4</version>
        <configuration>
          <container>
            <containerId>tomcat9x</containerId>
            <type>remote</type>
          </container>
          <configuration>
            <type>runtime</type>
            <properties>
              <cargo.protocol>http</cargo.protocol>
              <cargo.servlet.port>8080</cargo.servlet.port>
            </properties>
          </configuration>
          <deployer>
            <type>remote</type>
          </deployer>
          <deployables>
            <deployable>
              <groupId>org.jason</groupId>
              <artifactId>sample</artifactId>
              <type>war</type>
            </deployable>
          </deployables>
        </configuration>
        <executions>
          <execution>
            <id>tomcat1</id>
            <configuration>
              <properties>
<!--                <cargo.remote.username>jason</cargo.remote.username>-->
<!--                <cargo.remote.password>password</cargo.remote.password>-->
                <cargo.hostname>192.168.10.21</cargo.hostname>
              </properties>
            </configuration>
          </execution>
          <execution>
            <id>tomcat2</id>
            <configuration>
              <properties>
<!--                <cargo.remote.username>jason</cargo.remote.username>-->
<!--                <cargo.remote.password>password</cargo.remote.password>-->
                <cargo.hostname>192.168.10.22</cargo.hostname>
              </properties>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
1

There are 1 answers

1
J Fabian Meier On

I guess you need to define them in the <properties> section of your POM, not inside the configuration of the plugin.