Apache Karaf and Apache Commons Bundles
-
27-05-2021 - |
문제
Right so some really noob(this is my first deployment of a bundle to Karaf) questions for the Apache Karaf folks out there. I am deploying a bundle that uses a lot of the org.apache.commons.* bundles. When I deployed my bundle and then try to start it, Karaf threw a error about not finding org.apache.commons.pools for example. I did a bit of googling and ran the following:
osgi:install mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool
This installed the missing bundle and I hit the next one. While I understand that the required bundles are not installed into the OSGI container I have some questions that need clarification.
- From my understanding the bundle I am installing is using some sort of servicemix bundle. So I want to know is this needed, cant I just add a org.apache.commons.pool bundle instead of a full servicemix bundle?
- When I am missing a bundle how can I find out which maven url to use. For example say I needed a foobar bundle how would I go about adding the bundle if I dont know the url? Right now I cant start my bundle due to package=org.apache.log not being found. So how would I know how to add this?
- Difference between a bundle and feature?
Hope the questions are clear enough. I am making headway with karaf just need to clarify these points.
해결책
Not all the Java "jars" are OSGi compatible, they need to have the OSGi bundle manifest.
I follow this steps when I need to add a dependency from the console:
- Search the library at mvnrepository.com
Try to install it like this:
install mvn:[group-id]/[artifact-id]/[version]
If it's not an OSGi library then I search it at SpringSource. On this repository all the bundles are OSGi, but it's normal that they have outdated versions.
- My last option is to use the Karaf wrap deployer that let you deploy non-OSGi bundles. Check the user guide.
And about the features, a feature is just a set of bundles. Read this post for further details.