#StackBounty: #java #maven #jenkins #intellij-idea Jenkin build fails after maven dependencies upgrade

Bounty: 50

Recently, I was working on upgrading the dependencies of one of my team’s projects. After changes, project built successfully locally on my laptop. But the same code change threw compilation error on Jenkins.

The errors I am encountering is related to class file for xxx.xxx.xxx. not found in powermockito package. Attaching some relevant pieces of code for reference.

Pervious pom version used:

... some lines above it ...   

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!--dropwizard versions-->
    <dropwizard.version>1.3.5</dropwizard.version>
    <dropwizard.swagger.version>1.0.0-2-auth-SNAPSHOT</dropwizard.swagger.version>
    <dropwizard.bundle.version>1.3.5-1</dropwizard.bundle.version>
    <dropwizard.requestinfo>1.3.5-3</dropwizard.requestinfo>
    <dropwizard.rosey.data.provider.version>1.3.5-3</dropwizard.rosey.data.provider.version>
    <dropwizard.service.discovery>1.3.5-0</dropwizard.service.discovery>
    <dropwizard.rmq.actor.version>1.2.2-1</dropwizard.rmq.actor.version>
    <dropwizard.riemann.version>1.3.5-4</dropwizard.riemann.version>

    <!--hystrix versions-->
    <hystrix.dropwizard.version>0.4</hystrix.dropwizard.version>
    <hystrix.configurator.version>0.0.6</hystrix.configurator.version>
    <hystrix.version>1.5.3</hystrix.version>
    <hystrix.wrapper.version>1.0-SNAPSHOT</hystrix.wrapper.version>

    <!--internal clients-->
    <user-service-model.version>1.7.91</user-service-model.version>
    <kratos.version>0.8.2-SNAPSHOT</kratos.version>
    <rosey.dropwizard.config>1.14</rosey.dropwizard.config>

    <!--others-->
    <mysql.driver.version>5.1.38</mysql.driver.version>
    <okhttp3.version>3.4.1</okhttp3.version>
    <lombok.version>1.18.8</lombok.version>
    <junit.version>4.12</junit.version>
    <powemock.version>1.7.3</powemock.version>
    <h2.version>1.4.191</h2.version>
    <square.okhttp.version>3.4.1</square.okhttp.version>
    <rmq.version>4.1.0</rmq.version>
    <zookeeper.version>3.4.13</zookeeper.version>
    <curator.version>4.0.1</curator.version>
</properties>

... some lines below it ...

Current pom version used:

... some lines above it ...

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!--dropwizard versions-->
    <dropwizard.version>1.3.12</dropwizard.version>
    <dropwizard.swagger.version>1.3.7-1</dropwizard.swagger.version>
    <dropwizard.bundle.version>1.3.5-1</dropwizard.bundle.version>
    <dropwizard.requestinfo>1.3.5-8</dropwizard.requestinfo>
    <dropwizard.rosey.data.provider.version>1.3.5-6</dropwizard.rosey.data.provider.version>
    <dropwizard.service.discovery>1.3.12-3</dropwizard.service.discovery>
    <dropwizard.rmq.actor.version>1.3.12-1</dropwizard.rmq.actor.version>
    <dropwizard.db.sharding.bundle.version>1.3.12-3</dropwizard.db.sharding.bundle.version>
    <dropwizard.riemann.version>1.3.12-1</dropwizard.riemann.version>

    <!--hystrix versions-->
    <hystrix.dropwizard.version>0.4</hystrix.dropwizard.version>
    <hystrix.configurator.version>0.0.6</hystrix.configurator.version>
    <hystrix.version>1.5.3</hystrix.version>

    <!--internal clients-->
    <user-service-model.version>1.7.96-STAGE-SNAPSHOT</user-service-model.version>
    <kratos.version>0.9.6</kratos.version>
    <rosey.dropwizard.config>1.15</rosey.dropwizard.config>

    <!-- storage -->
    <aerospike.version>3.3.0</aerospike.version>
    <mock.aerospike.version>0.0.4</mock.aerospike.version>

    <!--others-->
    <okhttp3.version>3.4.1</okhttp3.version>
    <lombok.version>1.18.8</lombok.version>
    <junit.version>4.12</junit.version>
    <powemock.version>1.7.3</powemock.version>
    <guava.version>28.0-jre</guava.version>
    <h2.version>1.4.199</h2.version>
    <rmq.version>5.7.2</rmq.version>
    <zookeeper.version>3.4.13</zookeeper.version>
    <curator.version>4.2.0</curator.version>
    <sentinel.model.version>1.0-SNAPSHOT</sentinel.model.version>
</properties>

... some lines below it ...

Shortend error logs:

... some code above it ...  

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/MerchantResourceTest.java:[19,1] cannot access org.powermock.api.support.membermodification.MemberModifier
  class file for org.powermock.api.support.membermodification.MemberModifier not found
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/VPAResourceTest.java:[29,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/VPAResourceTest.java:[30,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/services/PrimerServiceTest.java:[28,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/services/PrimerServiceTest.java:[29,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/AddressResourceTest.java:[22,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/AddressResourceTest.java:[23,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/services/WalletServiceTest.java:[27,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/services/WalletServiceTest.java:[28,1] static import only from classes and interfaces
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/MerchantResourceTest.java:[24,25] cannot access org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner
  class file for org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner not found
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/VPAResourceTest.java:[37,25] incompatible types: java.lang.Class<org.powermock.modules.junit4.PowerMockRunner> cannot be converted to java.lang.Class<? extends org.junit.runner.Runner>
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/BaseResourceTest.java:[26,19] package org.mockito does not exist
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/BaseResourceTest.java:[30,26] package org.mockito does not exist
[ERROR] /var/lib/jenkins/jobs/UserService_Develop/workspace/src/test/java/com/xxxxxxx/userservice/resources/BaseResourceTest.java:[30,1] static import only from classes and interfaces

... some code below it ...

Experiment I did: When I removed the test scope from the powermockito dependency, everything worked like a charm.

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <version>${powemock.version}</version>
        <scope>test</scope>          <- This line
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>${powemock.version}</version>
        <scope>test</scope>          <- This line
    </dependency>

Pasting mockito’s maven dependency tree below

... some line above it ...

[INFO] +- org.powermock:powermock-api-mockito:jar:1.7.3:test
[INFO] |  +- org.powermock:powermock-api-mockito-common:jar:1.7.3:test
[INFO] |  |  - org.powermock:powermock-api-support:jar:1.7.3:test
[INFO] |  - org.mockito:mockito-core:jar:1.10.19:test
[INFO] +- org.powermock:powermock-module-junit4:jar:1.7.3:test
[INFO] |  +- org.powermock:powermock-module-junit4-common:jar:1.7.3:test
[INFO] |  |  +- org.powermock:powermock-reflect:jar:1.7.3:test
[INFO] |  |  - org.powermock:powermock-core:jar:1.7.3:test
[INFO] |  - org.hamcrest:hamcrest-core:jar:1.3:test

... some lines below it ...

Maven command which is executing on Jenkins, below sample is taken from console log:

Executing Maven:  -B -f /var/lib/jenkins/jobs/UserService_Develop/workspace/pom.xml -U clean package cobertura:cobertura docker:build docker:push -Pdocker -Dproject.version=1.8.23-SNAPSHOT -Dbuild.number=1501 -Dbuild.revision=9d8d00591c23b061b07e1a08c00ff024db8ba318 -Dmaven.test.failure.ignore=true -DskipTests -DargLine=-Xmx512m

Ideally, it should not have happened. I googled for few days found this blog Why your tests may pass locally but fail in Jenkins. Unfortunately, nothing seems to work for me. Need some assitance here. Thanks!


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.