Apache karaf how to easily install bundle from Maven repo - osgi

I am trying out Karaf and installed some bundle X. This bundle X complains about a missing requirement: Unresolved requirements ... osgi.wiring.package; (osgi.wiring.package=org.apache.commons.httpclient)]
Hence, I tried to provide the org.apache.commons.httpclient through bundle:install mvn:commons-httpclient/commons-httpclient/3.1 which worked.
But, after trying to start the X again, I still get the same error message.
thanks!

That jar is not a bundle, hence can't be deployed to karaf, it's just ignored.
Try
karaf#root>bundle:install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/3.1_7
Make it sure that your bundle has in their META-INF/MANIFEST.MF the osgi import declarations syntax. I assume that you use bndtools to generate the bundle.

Agree with #Antonio, for third party libraries which are not OSGi bundles you can also try to install them with wrap:
bundle:install -s wrap:mvn:commons-httpclient/commons-httpclient/3.1
This will create a basic OSGi MANIFEST for the library...
You can find more info here: http://karaf.apache.org/manual/latest/developers-guide/creating-bundles.html

Related

Can't force Apache Karaf to load a new version of the bundle (version w/o "-SNAPSHOT")

I've tried to update bundle in Karaf without changing its version. Version doesn't contain "-SNAPSHOT".
Is there a way to do it?
I've installed bundle to Apache Karaf through the mvn link
The code inside this bundle was changed without changing its (bundle's) version (according to some inner reasons).
Then I removed this bundle from Karaf, and from Nexus.
Next step was deploying new bundle to Nexus.
When I finally tried to install the "new" bundle, I saw there were no changes in it.
It looks like there is some cache inside Karaf where he stores bundles, that was already installed.
Adding flags like -c or -cc doesn't help.

Fast way to rebuild and reload opendaylight bundle

I am developing a bundle for opendaylight. Is there a quick way to just rebuild the bundle without the complete karaf environment?
Thanks in advance!
Max
You can rebuild the bundle, without anything else, by running Maven in the directory containing your bundle’s POM. If you’re on the command-line:
cd your-bundle-directory
mvn compile
(or mvn install etc. depending on what you want to do exactly).

Hystrix and OSGI bundle

I have used org.apache.servicemix.bundles.hystrix dependency to bundle Hystrix as OSGI bundle. However, I'm facing this issue:
org.osgi.framework.BundleException: Could not resolve module: [828]
Unresolved requirement: Import-Package: com.netflix.hystrix; version="[1.5.0,2.0.0)"
Can someone help me on this?
Thanks!
The error tells you that the bundle you try to install and resolve requires a certain package and that there is no bundle that offers this package.
So in you case the package com.netflix.hystrix is missing. This means that you either do not have the hystrix bundle installed or you installed a version that does not match the version range [1.5.0,2.0.0).

Jena OSGi bundle cannot start

I want to use Jena OSGi 3.0.0 version in Felix 2.0.3, but when I install the bundle I get the exception:
Unresolved constraint in bundle org.apache.jena.osgi [1]: package; (&(package=org.apache.commons.cli)(version>=1.3.0)(!(version>=2.0.0)))
Does this mean that the package org.apache.commons.cli is not contained in the jena-osgi bundle?
Any ideas how to solve this issue?
Yes, this means that the jena-osgi bundle imports package org.apache.commons.cli. You need to install the bundle that exports this package.
Funnily enough, this package is exported by a bundle named org.apache.commons.cli which you can get from Maven Central:
http://search.maven.org/#artifactdetails|commons-cli|commons-cli|1.3.1|jar

Apache Sling: unresolved package after Installing SlingShot sample bundle

I am Unable to run slingshot sample , apache sling i have followed these steps
Click here!
the package got installed but it didn't get activated. The detail collapsed view of bundle shows
org.apache.sling.api.resource,version=[2.2,2) -- Cannot be resolved
Your bundle import org.apache.sling.api.resource,version=[2.2,2) was not resolved.
Assuming that your sling installation is running, you should verify if the package org.apache.sling.api.resource is either not exported or exported in the wrong version.
If the package is present then adapt your import.
You didn't indicate how you built or started the Sling instance where you installed the Slingshot bundle.
I just tried with a Sling launchpad built from the launchpad/builder folder of the Sling source code, the Slingshot bundle starts without problems and the /slingshot/albums.html path mentioned in the sample's README.txt works.

Resources