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

com.google.gson.internal -- Cannot be resolved

Avatar

Level 2

Hi Team,

 

How to add embed-dependency in bnd-maven-plugin. wanna add com.google.gson

 

com.google.gson.internal -- Cannot be resolved

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Which version of AEM are you using @sathyaprakasha2 . In most of the latest version of AEM , google gson  bundle should be available in the felix console already. Can you check /system/console/depfinder and search for the archetype you want to install ? 

I have 6.5 version and I already have gson in my felix console. PFB the screenshot.  You can copy the dependency from here and add it in the pom.xml files under <dependencyManagement><dependencies> section.

 

 1) Add below dependency on your main pom.xml

<dependency>
	<artifactId>gson</artifactId>
	<version>2.8.5</version>
	<groupId>com.google.code.gson</groupId>
	<scope>provided</scope>
</dependency>

2) Add the below in your core/pom.xml

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

 

dep1.JPG

 

If it is not available in your Felix console , then you can treat it as a third party bundle and follow the article mentioned by @Ankur_Khare 

 

Hope this helps

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

Which version of AEM are you using @sathyaprakasha2 . In most of the latest version of AEM , google gson  bundle should be available in the felix console already. Can you check /system/console/depfinder and search for the archetype you want to install ? 

I have 6.5 version and I already have gson in my felix console. PFB the screenshot.  You can copy the dependency from here and add it in the pom.xml files under <dependencyManagement><dependencies> section.

 

 1) Add below dependency on your main pom.xml

<dependency>
	<artifactId>gson</artifactId>
	<version>2.8.5</version>
	<groupId>com.google.code.gson</groupId>
	<scope>provided</scope>
</dependency>

2) Add the below in your core/pom.xml

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

 

dep1.JPG

 

If it is not available in your Felix console , then you can treat it as a third party bundle and follow the article mentioned by @Ankur_Khare 

 

Hope this helps

Avatar

Level 2
Hi Veena , Thanks for your reply ! .. I have verified gson in flexi console but they excluded the particular package (com.google.gson.internal ) so we have added Export-Package: com.google.gson.*;version='2.8.6' ..its resolved our issue..

Avatar

Employee Advisor

In maven-bundle-plugin, <wrapImportPackage>;</wrapImportPackage>  would add all your dependencies as resources in the generated jar file and configure the bundle classpath for you.
bnd-maven-plugin does not use instructions in the POM. You have to do that in bnd file. in the link provided below will show you an example of -includeresource instruction and how to set your bundle classpath.

 

Please check the document for more information:

 

1. https://help.liferay.com/hc/en-us/articles/360018162491-Resolving-Third-Party-Library-Package-Depend...

Avatar

Employee

You're supposed to be directly referencing anything in the com.google.gson.internal package... that's why it's called "internal". 

See the big warning on the GSON JavaDocs site for these internal packages [1] that reads: Do NOT use any class in this package as they are meant for internal use in Gson. Infact, this package is no longer exported at all in later versions of GSON.

 

The fix is to update your code to depend on Gson's public API space.

 

[1] https://javadoc.io/doc/com.google.code.gson/gson/1.7.2/com/google/gson/internal/package-summary.html