Expand my Community achievements bar.

SOLVED

AEM SDK version upgrade to 2025.1.19149.20250116T154450Z-241100 in POM failing existing tests cases

Avatar

Level 1
Level 1

when trying to upgrade POM with version : 2025.1.19149.20250116T154450Z-241100 and found that test cases are failing with below error.

 

[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in com.cbdt.core.userreport.services.impl.ReportStoreServiceImplTest
[ERROR] saveReport_whenStoreRootPathExists_thenNewReportPageIsCreatedBasedOnStoreOptions Time elapsed: 0 s <<< ERROR!
java.lang.NoSuchMethodError: 'void com.google.gson.internal.ConstructorConstructor.<init>(java.util.Map, boolean)'
at com.abc.core.userreport.services.impl.ReportStoreServiceImplTest.<init>(ReportStoreServiceImplTest.java:24)

 

However, the same test cases are passed with version : 

 2024.6.16799.20240614T073455Z-240500 

 

The dependency for GSON is present, we have tried with 2.8.9 and 2.11.0 , but the issue remains the same and build is failing.

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>

 

The build is successful if the test cases are ignored.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi @RK7 ,

 

Try adding the scope as test in the gson dependency.

 

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>test</scope>
</dependency>

View solution in original post

4 Replies

Avatar

Level 7

The error is likely caused by a Gson version conflict between your project and the AEM SDK. Here's how to fix it:
1. Remove Gson version from your pom.xml to let AEM SDK manage it:

<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
</dependency>

2. Check for conflicts using mvn dependency:tree to see if multiple Gson versions are being pulled in.
3. Clean and rebuild the project with:

mvn clean install

4. If needed, align the Gson version in your dependencyManagement section.

Avatar

Correct answer by
Level 4

Hi @RK7 ,

 

Try adding the scope as test in the gson dependency.

 

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>test</scope>
</dependency>

Avatar

Level 1

Hi @chaudharynick 

Thank you for the quick fix I have the same issue, gson dependency has a test scope but its failing some of the tests. When reverting back to the version 2024 I don't have such problem.

Do you have any suggestion for me?

 

Thanks in advanced

Avatar

Level 1
Level 1

Tried with providing scope as test, still it gave the same  issue.