Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Error with mockito-core in cloud manager

Avatar

Employee Advisor

Hello,

 

We have upgrade all the junit versions in pom.xml and it worked absolutely fine in local server but when deployed in cloud manager with latest (2023.1) version, the build fails with below error:

15:31:46,075 [main] [ERROR] COMPILATION ERROR : 
15:31:46,076 [main] [INFO] -------------------------------------------------------------
15:31:46,080 [main] [ERROR] /build_root/build/underarmourcloudservice-p35450/ua-assetshare/core/src/test/java/com/ua/assetshare/collections/models/impl/UAHeaderImplTest.java:[17,19] cannot access org.mockito.Mock
  bad class file: /root/.m2/repository/org/mockito/mockito-core/5.0.0/mockito-core-5.0.0.jar(org/mockito/Mock.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
15:31:46,081 [main] [INFO] 1 error

 

pom.xml

----------

<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<!-- Prefer the latest version of AEM Mock Junit5 dependency -->
<version>5.1.2</version>
<scope>test</scope>
</dependency>

 

If we change the "mockito-core" version to 3.12.4, it builds fine.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Shelly,

 

You can include exec plugin to tell you the java version during the build, it will be located in the build logs.

 

<plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions> <execution> <id>java version printer</id>
<phase>initialize</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>mvn</executable> <arguments> <argument>-v</argument> </arguments> </configuration> </execution> </executions> </plugin>
 

 Have googled around and found this blog post too:

AEM as a Cloud Service & Java 11 Pipelines (theaemmaven.com)

 

Regards,

Peter

View solution in original post

4 Replies

Avatar

Community Advisor

Hi Shelly,

 

I assume on your local you got  Java 11 and pipeline fails with Java 1.8.

 

Create file .cloudmanager/java-version with 11 as content. [1] complete docs on subject.

 

This error indicates that code executed on Java 1.8, requires Java 11.

 

As per mockito-core release notes it's minimum requirements are Java 11.

 

So we need to point to cloudmanager pipeline you want Java 11 by creating relevant config.

 

[1] Build Environment | Adobe Experience Manager

 

Regards,

Peter

Avatar

Employee Advisor

Still getting the same issue. Is there a way to check cloud manager Java version?

 

Avatar

Correct answer by
Community Advisor

Hi Shelly,

 

You can include exec plugin to tell you the java version during the build, it will be located in the build logs.

 

<plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions> <execution> <id>java version printer</id>
<phase>initialize</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>mvn</executable> <arguments> <argument>-v</argument> </arguments> </configuration> </execution> </executions> </plugin>
 

 Have googled around and found this blog post too:

AEM as a Cloud Service & Java 11 Pipelines (theaemmaven.com)

 

Regards,

Peter

Avatar

Community Advisor

The version being used in your local server is version 5.0.0, which has a class file version of 55.0, but the version being used in the cloud manager is an older version with a class file version of 52.0.

 

To resolve this issue, you'll need to ensure that the same version of the mockito-core library is being used in both your local server and the cloud manager. 

You would need to find the version which has class version of 52.0 and then use that in the pom file.