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.
Please use this thread to ask the related questions.
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.
@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.