Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

AEM - AMS - Development - I need GSON 2.8.9

Avatar

Level 7

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>
1 Accepted Solution

Avatar

Correct answer by
Level 7

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

View solution in original post

5 Replies

Avatar

Employee

@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 .

 

Avatar

Level 4

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>

Avatar

Level 7

Thanks folks. I tried the above exclusons idea with different versions of GSON.

2.8.9 didn't work.

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>compile</scope>
</dependency>

I tried 2.10.1 which produces this message.

 

ERROR!
java.lang.NoSuchMethodError: com.google.gson.internal.ConstructorConstructor

 

Any suggestions?  Our uberjar api is just set to 6.5.0 since our 6.5 upgrade

Avatar

Level 7

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

 

Gson gson = new Gson();

ERROR!
java.lang.NoSuchFieldError: FACTORY

Avatar

Correct answer by
Level 7

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