Unable to use external jars in aem environment (OSGi) | Community
Skip to main content
Level 2
April 3, 2019

Unable to use external jars in aem environment (OSGi)

  • April 3, 2019
  • 5 replies
  • 9317 views

We have a third party jar which we want to use in our AEM project. We have added dependencies in pom files, it is resolving those jars only in eclipse but when it comes to Felix console it is not showing under the imported package and not giving any jars that have been added in dependencies. Hence, we are getting classnotfound exception while calling any methods from a jar.

Also, is it feasible if external project jar has the dependency on spring jar, can we include it in AEM as well?

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

5 replies

Adobe Employee
April 3, 2019

I believe you need to add that jar to the OSGI console in order to use the services associated with that jar file.

You can include any jar within AEM as long as it is able to resolve the imported/exported bundle list mentioned in the metadata of that jar file

arunpatidar
Community Advisor
Community Advisor
April 3, 2019

worth to notice if jars are not osgi bundles.

You can not use jar directly in AEM, need to converted the Jar into bundle with help of the link "https://helpx.adobe.com/experience-manager/kb/ConvertAJarIntoOsgiBundle.html" , Now your bundle is ready to be uploaded into AEM through felix console.

Arun Patidar
Level 2
April 4, 2019

what to do in a scenario where the jar file has dependencies on other external jar files.I am facing this issue where i create the osgi bundle from normal jar and  upload it on AEM console but when I am trying to hit my servlet there it needs third party (spring)jars , so it giving
java.lang.NoClassDefFoundError: org/springframework/web/client/RestClientException.What can I do in this case?

Gaurav-Behl
Level 10
April 4, 2019

If you want to use Spring in AEM for "some use case", then use Spring DM or Blueprint or similar container. One single jar file wouldn't work, you'd need to setup entire container.

If you are getting classnotfound exception, then package the jar (non-spring jars, packaging spring bundles won't work), and update your pom.xml's "maven-bundle-plugin" accordingly

April 4, 2019

If that jar's not OSGi support, you should convert them to OSGi jars by simply adding the manifest file.

Here you go how to do that: How to Convert a jar File into an OSGi Bundle

Adobe Experience Manager (AEM/CQ5) : How to Convert a jar File into an OSGi Bundle

April 4, 2019

Hi @rasikawanjari

Make sure you should use only OSGi support spring versions.