Expand my Community achievements bar.

Use 3rd party API or JAR or Dependency in AEM | AEM Community Blog Seeding

Avatar

Administrator

2/14/21

BlogImage.jpg

Use 3rd party API or JAR or Dependency in AEM by Rahul Aggarwal

Abstract

A 3rd party jar is one which is not present as a bundle in AEM OSgI. If you want to use API’s from a 3rd party jar in AEM then it needs to be added to AEM OSGI.

If you try to upload a 3rd party jar in osgi then it won’t, get uploaded. To upload it in osgi it needs to be osgi specific with MANIFEST.MF file. OSGI bundle is nothing but jar with MANIFEST.mf file.

Lets take the example of apollo client which is not available in aem osgi. Apolloclient can be used to make graphql requests using graphql query.


Problem statement:
Example: If you are using Apolloclient API for sending graphql requests in backend. Then you probably already included the dependencies in POM to resolve the API’s. If you do a maven build it will build successfully and deploy to AEM. However, if you check in OSGI the core bundle will NOT be in active state. If you dig deeper the apolloclient dependencies are not resolved in the bundle. Reason for this is apolloclient is not available in AEM runtime. You will probably also get internal server error if you try to access any of the site pages.


Solution:
All jars required for the apollo client to work in aem osgi, should be embedded in core bundle and available in its classpath. All transitive dependencies of apolloclient need to be added as well. This way we are adding all the jars to bundle classpath and these jars wont be available as separate bundles in osgi.

Add all jars to include-resource of bnd maven plugin in core pom. All these jars need to be added to classpath of the plugin.

Read Full Blog

Use 3rd party API or JAR or Dependency in AEM

Q&A

Please use this thread to ask the related questions.