Expand my Community achievements bar.

SOLVED

com.google.code.gson not getting resolved

Avatar

Former Community Member

Hi,

I have included google gson dependency in the pom.xml of my project as shown below:

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

I am able to build the project without any issues but when I am hitting the URL, the page does not load. I can see that in the system/console the project bundle is not getting started.  Further, upon looking in the details of the bundle, it shows an error "com.google.gson,version=[2.2,3) -- Cannot be resolved"

Any idea what could possible go wrong.

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Level 10

Read this Sling Article that uses a JSON API:

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

It uses org.json.simple.JSONObject API similar to GSON. As shown in the article - you have to wrap the JAR file (in your case -- com.google.code.gson) in a bundle fragment and deploy to CQ. You can follow the same steps as talked in the article. Replace JSONObject API with GSON API. 

Hope this helps. 

View solution in original post

3 Replies

Avatar

Employee Advisor

Does this artifact represent a OSGI bundle? And even if it does, do you deploy this artifact into CQ?

Jörg

Avatar

Correct answer by
Level 10

Read this Sling Article that uses a JSON API:

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

It uses org.json.simple.JSONObject API similar to GSON. As shown in the article - you have to wrap the JAR file (in your case -- com.google.code.gson) in a bundle fragment and deploy to CQ. You can follow the same steps as talked in the article. Replace JSONObject API with GSON API. 

Hope this helps. 

Avatar

Former Community Member

Thanks for the article. It really helped. I have been able to get the code with simple Json working but not with Gson. However, I am going ahead with implementing simple Json. Doesn't look much different from Gson anyway.