Hello all,
I'm using a third party library in my OSGi bundle.
I've added their dependency to my pom.xml file.
When I run mvn clean install it builds successfully.
However when I install the OSGi bundle it says three packages can not be resolved.
What can the issue be here?
BTW this dependency works as a regular maven project -- I have tested it out and all classes were used in code.
Here is the library I'm using:
http://bican.net/wordpress-java/
Thanks All!
Solved! Go to Solution.
Views
Replies
Total Likes
To get this working in AEM (assuming the missing packages are all in this JAR) - you need to wrap this JAR file into an OSGi bundle:
jwordpress-0.6.4.jar
You can download this JAR here:
http://mvnrepository.com/artifact/net.bican/jwordpress/0.6.4
Use the Eclipse plug-in project as discussed in the article I linked to above.
When you reference the lib in Maven POM file - that is simply to successfully compile the bundle - not to successfully run the OSGi bundle in AEM.
To run the bundle in AEM, another OSGi bundle has to export that package. You can see if that package is in AEM by using the Dependency finder located here:
http://localhost:4502/system/console/depfinder
If there is a bundle that exposes the package - it will tell you by showing a POM dependency. If there is no bundle that exports the package - then it will be empty.
So in your case - it sounds like you do not have your 3rd party JAR wrapped in an OSGi bundle (a separate bundle). Now the good news is its very easy to do so.
You can use Eclipse plug-in project to do so. See how we wrapped the 3rd party JSON simple JAR file (as an example).
See this community article to learn how to do that:
https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
So in this article - we have a Sling Servlet that uses the Simple JSON library. Had i not wrapped it and deployed to AEM - the SLing Servlet that depends on the SImple JSON JAR file would not work. So for your use case - you are missing the dependency OSGi that contains and exports the 3rd party JAR.
Views
Replies
Total Likes
To get this working in AEM (assuming the missing packages are all in this JAR) - you need to wrap this JAR file into an OSGi bundle:
jwordpress-0.6.4.jar
You can download this JAR here:
http://mvnrepository.com/artifact/net.bican/jwordpress/0.6.4
Use the Eclipse plug-in project as discussed in the article I linked to above.
Thanks scott that fixed the initial problem but now my servlet is spitting out this:
java.lang.NoClassDefFoundError: Could not initialize class
Those classes that it lists are all classes that are found in the third party jar.
I made the exported bundle as you pointed out in that article.
Any suggestions?
Views
Replies
Total Likes
Adding this 3rd party JAR was a required step to work with this lib in an OSGi service.
I also sent you an email - I said I would setup a connect session if you want on Monday to walk through this use case. This may make a good helpx communtiy article as well so future community members working with this lib will not have this issue. We will get this resolved.
Send me back an email.
Views
Replies
Total Likes
smacdonald2008 wrote...
Adding this 3rd party JAR was a required step to work with this lib in an OSGi service.
I also sent you an email - I said I would setup a connect session if you want on Monday to walk through this use case. This may make a good helpx communtiy article as well so future community members working with this lib will not have this issue. We will get this resolved.
Send me back an email.
Scott, if he chooses to do this, would you be able to set up a general web meeting? I'd VERY much like to participate too, as I'm currently trying to export 3rd party jar files in an OSGI bundle and running into issues figuring out how to specify the Import-Package header.
I take it that I have to figure out all of the dependencies of the jar files I'm exporting in the bundle, and continue doing this for each set of dependent jars until the entire dependency chain is worked out??? Is this correct? Most of the helpx articles you link simply say "Ensure that the Import-Package header is populated", but doesn't tell you in detail how to go about accomplishing that step by step.
Views
Replies
Total Likes
Views
Likes
Replies