com.google.code.gson not getting resolved | Community
Skip to main content
October 16, 2015
Solved

com.google.code.gson not getting resolved

  • October 16, 2015
  • 3 replies
  • 6797 views

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,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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. 

3 replies

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

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

Jörg

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

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. 

October 16, 2015

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.