java – Cant find required class org/apache/commons/lang3/ArrayUtils while building on Jenkins

OS Java8 jdk1.8

When running my build using mvn clean install -P TestExecutor on Jenkins I get the following error:

[ERROR] Failed to execute goal net.masterthought:maven-cucumber-reporting:5.7.0:generate (generate-cucumber-reports) on project testing: Execution generate-cucumber-reports of goal net.masterthought:maven-cucumber-reporting:5.7.0:generate failed: A required class was missing while executing net.masterthought:maven-cucumber-reporting:5.7.0:generate: org/apache/commons/lang3/ArrayUtils

Locally it’s running and just fine. Here is the catch: I don’t find the org/apache/commons/lang3/ in my local m2 repository (I do have the commons-lang3) and it does not appear on the mvn dependency:tree list.

So it seems Jenkins specifically need to have the lang3 jar? So I add the version 3.4 (as mentioned in comments, previous one was 3.12) dependency in my POM like this

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>lang3</artifactId>
    <version>3.4</version>
</dependency>

So I’m not sure what I am doing wrong

Here is my POM

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xxx</groupId>
    <artifactId>testing</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <cucumber.version>7.3.3</cucumber.version>
        <selenium.version>4.1.4</selenium.version>
        <awaitility.version>4.2.0</awaitility.version>
        <assertj.version>3.22.0</assertj.version>
        <commonsmodel.version>5.3.3</commonsmodel.version>
        <maven.compiler.version>3.10.1</maven.compiler.version>
        <maven.surefire.version>3.0.0-M6</maven.surefire.version>
        <commons-lang3.version>3.4</commons-lang3.version>
        <junit-jupiter-engine.version>5.8.2</junit-jupiter-engine.version>
        <maven-cucumber-reporting.version>5.7.0</maven-cucumber-reporting.version>
    </properties>

    <dependencies>


        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit-platform-engine</artifactId>
            <version>${cucumber.version}</version>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <version>1.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit-jupiter-engine.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>net.jodah</groupId>
            <artifactId>failsafe</artifactId>
            <version>2.4.4</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${selenium.version}</version>
        </dependency>

        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>${cucumber.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>

        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>${maven-cucumber-reporting.version}</version>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>TestExecutor</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${maven.compiler.version}</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.version}</version>
<!--                        <dependencies>-->
<!--                            <dependency>-->
<!--                                <groupId>org.junit.jupiter</groupId>-->
<!--                                <artifactId>junit-jupiter-engine</artifactId>-->
<!--                                <version>${junit-jupiter-engine.version}</version>-->
<!--                            </dependency>-->
<!--                        </dependencies>-->
                        <configuration>
                            <includes>
                                <includes>**/ExecutorTest.java</includes>
                            </includes>
                        </configuration>
                    </plugin>
                    <!--cucumber report plugin-->
                    <plugin>
                        <groupId>net.masterthought</groupId>
                        <artifactId>maven-cucumber-reporting</artifactId>
                        <version>${maven-cucumber-reporting.version}</version>
                        <executions>
                            <execution>
                                <id>generate-cucumber-reports</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <projectName>Automation report</projectName>
                                    <outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
                                    <inputDirectory>${project.build.directory}/</inputDirectory>
                                    <jsonFiles>
                                        <param>**/*.json</param>
                                    </jsonFiles>
                                    <checkBuildResult>false</checkBuildResult>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>


</project>

Edit: the full error log reads like this

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.662 s
[INFO] Finished at: 2022-06-14T17:04:00+02:00
[INFO] Final Memory: 29M/258M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal net.masterthought:maven-cucumber-reporting:5.7.0:generate (generate-cucumber-reports) on project testing: Execution generate-cucumber-reports of goal net.masterthought:maven-cucumber-reporting:5.7.0:generate failed: A required class was missing while executing net.masterthought:maven-cucumber-reporting:5.7.0:generate: org/apache/commons/lang3/ArrayUtils
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>net.masterthought:maven-cucumber-reporting:5.7.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/appl/xxx/maven/repo/net/masterthought/maven-cucumber-reporting/5.7.0/maven-cucumber-reporting-5.7.0.jar
[ERROR] urls[1] = file:/appl/xxx/maven/repo/net/masterthought/cucumber-reporting/5.7.0/cucumber-reporting-5.7.0.jar
[ERROR] urls[2] = file:/appl/xxx/maven/repo/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: org.apache.commons.lang3.ArrayUtils
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

Leave a Comment