AEM - AMS - Development - I need GSON 2.8.9 | Community
Skip to main content
Level 6
June 30, 2025
Solved

AEM - AMS - Development - I need GSON 2.8.9

  • June 30, 2025
  • 1 reply
  • 540 views

hi folks,

I have GSON 2.8.0 but I've been told to upgrade to 2.8.9.

Just editing the Pom file  doesn't seem to work for me. Cloudmanager doesn't find the updated GSON.

 

I changed my main pom.xml file.

 

Any ideas what I'm doing wrong.?  Could it be my UBER jar api version?

thanks

Fiona

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
Best answer by fionas76543059

If I try 2.8.9 GSON, I get this problem in a Unit test

 

Gson gson = new Gson();

ERROR!
java.lang.NoSuchFieldError: FACTORY


I solved this  by deleting some of my unit tests that used GSON. There is some mismatch with the  junit and GSON versions.

1 reply

Ekhlaque
Adobe Employee
Adobe Employee
June 30, 2025

@fionas76543059  ,you need to explicitly override it.

Use  <dependencyManagement>, and ensure the scope is not limited

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.9</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

You will then also need to reference that dependency in your <dependencies> section in the module(s) where you use GSON, but without a <version> tag:

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

This ensures over the Uber Jaryour version wins .

 

Sid_Gour
Level 3
July 1, 2025

We can also try to exclude the dependency from Uber.jar.

<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>${aem.uber.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
</dependency>

fionas76543059AuthorAccepted solution
Level 6
July 2, 2025

If I try 2.8.9 GSON, I get this problem in a Unit test

 

Gson gson = new Gson();

ERROR!
java.lang.NoSuchFieldError: FACTORY


I solved this  by deleting some of my unit tests that used GSON. There is some mismatch with the  junit and GSON versions.