Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Resolve dependencies by converting Jar to Bundle | AEM 6.5.5 | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

Resolve dependencies by converting Jar to Bundle | AEM 6.5.5 by AEM Queries & Solutions

Abstract

Many a times we come across such scenarios when we have to use some dependencies which are not resolved by our AEM server. In that case our project bundle doesn’t gets resolved and we see the dependency errors marked in red.

org.apache.oltu.oauth2.client,version=[1.0,2) — Cannot be resolved

In this case we will download the dependency Jar from the maven repository and convert it into OSGI bundle and deploy it to the AEM server.

Process to convert Jar to Bundle:
1. Go to File –> New –> Other –> Plug-in from existing JAR Archives

Click next and the add the JAR that we downloaded using the option Add External JAR and click next and provide the following configuration as per the requirement. And then click next and finish.

Now go to MANIFEST.MF file and remove the version from the imported packages as shown below.

Now switch to Runtime tab and click on add in Export packages column to add the packes and dependency that we want to export as part of this bundle. These are the same dependencies which were not getting resolved as bundle.

Exporting packages
Don’t forget to save the changes after updating the MANIFEST.MF file.

Now right click on the plugin project created in package explorer and click on Export and select Deployable plug-ins and fragments

Now provide the path where you want to save the deployable bundle locally and click on finish. Now go to the specified location and you will find the deployable bundle.

Installing directly on felix console is not the best way to resolve the dependency so we will deploy it as part of embed code.

Now create a install folder in your local code-base at ../apps//install/
And now embed the code in ui.apps POM.xml


org.apache.solr
solr-solrj
/apps//install


Now when the code is built, this bundle gets deployed on the felix console and when we go and check the dependency it will be resolved as our project bundle is now importing the dependency from the created bundle’s exported packages.

Read Full Blog

Resolve dependencies by converting Jar to Bundle | AEM 6.5.5

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6 Replies

Avatar

Administrator

Thank you for creating these blogs.



Kautuk Sahni

Avatar

Administrator

Thank you for creating these blogs.



Kautuk Sahni

Avatar

Level 1

I was wondering is there a way to embed the external dependencies in pom.xml file using bnd-maven-plugin.

 

I know using "maven-bundle-plugin" you can embed external dependencies using following syntax.

<Embed-Dependency>jackson-core</Embed-Dependency>

Avatar

Community Advisor

@sairatnap159965 - Yes we can. As you can see in the blog, I didn't had SolrJ as part  of maven dependency which was something external to AEM resolution. So I embedded it as bundle as part of the ui.apps POM. 

Avatar

Level 1

Hi @Nikhil-Kumar ,

I am in a need to use aws-java-sdk jar. I have crated the bundle as per the process mentioned in the blog and also put it under /app/<project-name>/install folder. What should I use in the embed section for groupid and artifact id

<embedded>
<groupId>?</groupId>
<artifactId>?</artifactId>
<target>/apps/<project-name>/install</target>
<embedded>