Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Using 3rd Party (External)Jar in OSGi bundles

Avatar

Level 10

All,

  I have created a bundle in crxde lite and I have a dependency of a 3rd Party (External)jar and I have followed the below steps

1. Convert the 3rd party jar to bundle and install in felix console. Its installed and active.

2. import the class which is used in my bundle slingServlet

3. I have also mentioned that package in 'Import-Package' in the .bnd file

When I start my OSGi bundle, it successfully gets installed but gives a runtime exception saying that 3rd party package is not existing. 

What needs to be changed/checked here ?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Use Eclipse and the plug-in project to wrap the 3rd party JAR into an OSGi bundle fragment. That is a better way than using CRXDE lite. 

Here is an article that shows this concept - we wrapped the JSON jar that the servlet used to encode posted data. 

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Note this section in this article:

Add the org.json.simple.JSONObject data type to Adobe CQ 

Add the org.json.simple.JSONObject class to Adobe CQ. The reason is because the doPost method in the Sling Servlet uses this class to encode form data to JSON formatted data. If you do not add this class to Adobe CQ, then you are unable to place the OSGi bundle that contains the Sling Servlet into an Active state....

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Use Eclipse and the plug-in project to wrap the 3rd party JAR into an OSGi bundle fragment. That is a better way than using CRXDE lite. 

Here is an article that shows this concept - we wrapped the JSON jar that the servlet used to encode posted data. 

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Note this section in this article:

Add the org.json.simple.JSONObject data type to Adobe CQ 

Add the org.json.simple.JSONObject class to Adobe CQ. The reason is because the doPost method in the Sling Servlet uses this class to encode form data to JSON formatted data. If you do not add this class to Adobe CQ, then you are unable to place the OSGi bundle that contains the Sling Servlet into an Active state....