We are developing a proof of concept using AEM Correspondence Management and need to do a call to a REST service to retrieve data to prefill the correspondence letter templates. To do the POST we are trying to use com.sun.jersey.api.client which we have in our Maven repository and have also successfully built as a bundle in system/console/bundles according to: Adobe Experience Manager Help | Submitting Adobe Experience Manager form data to Java Sling Servlets under the section To create an OSGi bundle fragment that contains the org.json.simple.JSONObject class, perform these tasks.
However, although we reference this in our POM file, the imports are not resolving. Is there something we need to do within our POM file or somewhere else to reference the OSGi bundle we have installed?
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
java.lang.Error: Unresolved compilation problems:
The import com.sun.jersey cannot be resolved
The import com.sun.jersey cannot be resolved
The import com.sun.jersey cannot be resolved
Client cannot be resolved to a type
Client cannot be resolved
WebResource cannot be resolved to a type
ClientResponse cannot be resolved to a type
ClientResponse cannot be resolved to a type
ClientResponse cannot be resolved to a type
Thank you!
Solved! Go to Solution.
Views
Replies
Total Likes
The reason for the imports not getting resolved is when corresponding bundles are not available on AEM. Although you've added the dependency in POM that doesn't exist in AEM. So, either you'll have to explicitly installed "com.sun.jersey" jar in AEM web console or you can make this bundle as a part of your maven build so once you install the package, that bundle will be installed automatically.
To embedded bundle in maven project package build, go to ui.apps pom.xml and add dependency in <embeddeds></embeddeds> tags.
E.g.
Hope this helps!
Views
Replies
Total Likes
The reason for the imports not getting resolved is when corresponding bundles are not available on AEM. Although you've added the dependency in POM that doesn't exist in AEM. So, either you'll have to explicitly installed "com.sun.jersey" jar in AEM web console or you can make this bundle as a part of your maven build so once you install the package, that bundle will be installed automatically.
To embedded bundle in maven project package build, go to ui.apps pom.xml and add dependency in <embeddeds></embeddeds> tags.
E.g.
Hope this helps!
Views
Replies
Total Likes
I agree with the options but I guess the code snippet in incorrect
Views
Replies
Total Likes
Hi Vivek,
I'm using the same code snippet in ui.apps pom.xml and it's working fine. In ui.apps pom.xml, there's already an embed of core project core bundle.
Use the <embedded></embedded> similar way and add groupId and artifect ID of dependency you want to include part of the package.
I'm not aware of the project pom structure differs with the different version of the archetype.
Views
Replies
Total Likes
This article works - been tested many times. What you are missing is you have not followed the instructions in the doc to wrap the JAR into an OSGI bundle and deploy to AEM.
Watch the video here where we step through all the steps and show it working:
Scott's Digital Community: Submitting Adobe Experience Manager form data to custom Sling Servlets
Views
Replies
Total Likes
Wrapping JAR into as OSGi bundle is one option but not the only one. I find the maven way better as it is lesser of manual effort and I get the flexibility of using dependency private to the bundle or exposing it.
himanshusinghal : I was referring to the changes that one needs to make in maven-bunle-plugin.. Apache Felix - Apache Felix Maven Bundle Plugin (BND) What you mentioned looks to be a different way of doing it.. Do you have sample code/github link that you can share. Good to know more ways of doing things
Views
Replies
Total Likes
Views
Likes
Replies