Hi,
I have a java project. Which is using some 3rd party jar files. Dependencies for those jar files not available. I want to integrate that java project into AEM. How to convert those 3rd party jar files into bundles and how to import them in my AEM project?
Solved! Go to Solution.
Views
Replies
Total Likes
If those jar files are not required by your other bundles, then why not simply embed them in your custom bundle[1]? There is no need to create more bundles for the sake of it, I have been on projects where this has happened and often, simply embedding the jars would have been sufficient.
Regards,
Opkar
[1] http://www.sergiolopes.eu/2014/04/adding-jars-to-osgi-bundles-with-maven/
Views
Replies
Total Likes
Hi
There is a community article covering jar to OSGI bundle.
Link:- https://helpx.adobe.com/experience-manager/kb/ConvertAJarIntoOsgiBundle.html
Here's a very simple way of turning an existing jar file in an OSGi bundle, while keeping control on exported packages.
The example creates an OSGi bundle from the attached junit-4.4.jar.
Note: The method below only works in a scenario where the jar file has no dependencies on other external jar files.
Manifest-Version: 1.0 Created-By: myself Bundle-ManifestVersion: 2 Bundle-Name: JUnit 4.4 bundle Bundle-Description: Package junit 4.4 in an OSGi bundle Bundle-Version: 4.4.0 Bundle-ClassPath: .,junit-4.4.jar Bundle-SymbolicName: org.junit.framework Export-Package: junit.framework,junit.extensions,org.junit.runner,org.junit,junit.textui
Bundle-ClassPath
header is set to allow embedding the original jar as is. Make sure its value matches the filename of the jar that you are going to embed in the bundle.Export-Package
is a list of packages contained in the jar that you would like to make available to other bundles running in the OSGi Container.jar cvfm junit-4.4-bundle.jar manifest.txt junit-4.4.jar
manifest.txt
is the name of the manifest file created above.Export-Package
above, using the classes of the embedded junit-4.4.jar.I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
kautuksahni wrote...
Hi
There is a community article covering jar to OSGI bundle.
Link:- https://helpx.adobe.com/experience-manager/kb/ConvertAJarIntoOsgiBundle.html
Answer, Resolution
Here's a very simple way of turning an existing jar file in an OSGi bundle, while keeping control on exported packages.
The example creates an OSGi bundle from the attached junit-4.4.jar.
Note: The method below only works in a scenario where the jar file has no dependencies on other external jar files.
Start by creating a the jar's manifest file:
Manifest-Version: 1.0 Created-By: myself Bundle-ManifestVersion: 2 Bundle-Name: JUnit 4.4 bundle Bundle-Description: Package junit 4.4 in an OSGi bundle Bundle-Version: 4.4.0 Bundle-ClassPath: .,junit-4.4.jar Bundle-SymbolicName: org.junit.framework Export-Package: junit.framework,junit.extensions,org.junit.runner,org.junit,junit.textui
Bundle-ClassPath
header is set to allow embedding the original jar as is. Make sure its value matches the filename of the jar that you are going to embed in the bundle.
Export-Package
is a list of packages contained in the jar that you would like to make available to other bundles running in the OSGi Container.
Jar file
Get the jar file, in our case fromhttp://mirrors.ibiblio.org/pub/mirrors/maven2/junit/junit/4.4/junit-4.4.jarCreate the bundle jar file by running the following command:
jar cvfm junit-4.4-bundle.jar manifest.txt junit-4.4.jar
Where
manifest.txt
is the name of the manifest file created above.
That's it - the resulting jar file (attached to this page as an example) is an OSGi bundle the exports the packages listed inExport-Package
above, using the classes of the embedded junit-4.4.jar.
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Thanks Kautunk Sahni,
But, my jar file has dependency on other jar files.
Views
Replies
Total Likes
Hey,
Have you looked at bndtools? [1]
[1] https://github.com/bndtools/bndtools/wiki/How-to-Wrap-Bundles
Thanks,
Peter
Views
Replies
Total Likes
You can use an Eclipse plugin project. It works very nicely. We have a lot of community articles that show how to do this task. For example, notice how we wrap the simple JSON JAR in this article:
https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
If those jar files are not required by your other bundles, then why not simply embed them in your custom bundle[1]? There is no need to create more bundles for the sake of it, I have been on projects where this has happened and often, simply embedding the jars would have been sufficient.
Regards,
Opkar
[1] http://www.sergiolopes.eu/2014/04/adding-jars-to-osgi-bundles-with-maven/
Views
Replies
Total Likes
Hi
You may also refer to this article Link:http://www.wemblog.com/2012/04/how-to-integrate-3rd-party-jar-file-in.html .
I hope this would help you.
And thank you Opkar Gill, this is new learning for me :).
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies