Expand my Community achievements bar.

How to handle third party Java dependencies when developing OSGi bundles

Avatar

Level 10

Sometimes, AEM developers may struggle with how to work with third-party dependencies when developing custom OSGi services/servlets. We have seen threads in the forums that state that although they referenced the correct Maven POM dependencies, the bundle will not start in AEM. For example: 

<dependency>
            <groupId>net.bican</groupId>
            <artifactId>jwordpress</artifactId>
            <version>0.6.2</version>
            <scope>provided</scope>
      </dependency>

Simply by referencing  this dependency (net.bican)  in the POM file, this action does not place the package in the OSGi service container. As a result, this compiled bundle will not start in AEM without getting the package into AEM.

That is, if bundle A imports Java package X then in order for that bundle to be active in AEM, an AEM OSGi bundle must export package X. Otherwise, the bundle will not start. Just by referencing package X in your Maven POM file does not satisfy the requirement of getting package X into AEM. 

To show this concept in action, see this AEM community article. It discusses this use case and how to work with third-party Java dependencies. As an example use case - an AEM component that integrates with WordPress was developed. See:

Developing AEM components that display WordPress information

2 Replies

Avatar

Level 10

Tested on Chrome, Firefox, IE10, MS Edge.. Working fine...

Thanks scott

Avatar

Level 10

Yes, Its working fine. I have tested it. Very nice article Scott!!

Thanks,
Ratna Kumar.