how to fix org.osgi.framework.BundleException - java

I'm running ONOS and when I want to add my module to its core I get this exception.
that was OK before but when I changed my OS, I get this error.
I've tried lots of ways but none of them fits my problem.
I also have no POM file to add dependency.
any other suggestions would be appreciated
ERROR: Bundle sdn.FANA.optical.optical [178] Error starting mvn:sdn.FANA.optical/optical/1.0 (org.osgi.framework.BundleException: Unresolved constraint in bundle sdn.FANA.optical.optical [178]: Unable to resolve 178.0: missing requirement [178.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.karaf.shell.api.action)(version>=4.2.0)(!(version>=5.0.0))))
org.osgi.framework.BundleException: Unresolved constraint in bundle sdn.FANA.optical.optical [178]: Unable to resolve 178.0: missing requirement [178.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.karaf.shell.api.action)(version>=4.2.0)(!(version>=5.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
at java.lang.Thread.run(Thread.java:748)

This error message says that your bundle depends on the package org.apache.karaf.shell.api.action, version range [4.2.0, 5.0.0).
Whenever a bundle has an import, it must be matched by a corresponding export from another bundle. So you need to install the bundle that exports the package org.apache.karaf.shell.api.action, with version at least 4.2.0 and less than 5.0.0.

Related

"org.osgi.framework.BundleException: Unable to resolve" with Maven's dependency

I am new to AEM/Maven, and was following this simple tutorial to add the json-simple dependency.
Here is what I added to my pom.xml, and clicked on sync on top right to download that package.
you can see the full pom.xml here.
But when I install with mvn clean install -PautoInstallBundle, the build is success, but in my logs I get the following error message:
27.07.2022 20:00:15.531 *ERROR* [Background Update rampup.core (619)] org.apache.felix.http.jetty Cannot install or update bundle from /var/folders/hh/yvvgql191_l3vb9km9bxgpm80000gp/T/install2076326317699076133.tmp (org.osgi.framework.BundleException: Unable to resolve rampup.core [619](R 619.34): missing requirement [rampup.core [619](R 619.34)] osgi.wiring.package; (&(osgi.wiring.package=org.json.simple)(version>=1.1.0)(!(version>=2.0.0))) Unresolved requirements: [[rampup.core [619](R 619.34)] osgi.wiring.package; (&(osgi.wiring.package=org.json.simple)(version>=1.1.0)(!(version>=2.0.0)))])
org.osgi.framework.BundleException: Unable to resolve rampup.core [619](R 619.34): missing requirement [rampup.core [619](R 619.34)] osgi.wiring.package; (&(osgi.wiring.package=org.json.simple)(version>=1.1.0)(!(version>=2.0.0))) Unresolved requirements: [[rampup.core [619](R 619.34)] osgi.wiring.package; (&(osgi.wiring.package=org.json.simple)(version>=1.1.0)(!(version>=2.0.0)))]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4368)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2281)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.webconsole.internal.core.BaseUpdateInstallHelper.run(BaseUpdateInstallHelper.java:198) [org.apache.felix.webconsole:4.6.2]
at java.base/java.lang.Thread.run(Thread.java:834)
I have looked here and here. They talk about installing an export bundle, or to install the missing org.json.simple, but their solution are too high level for me.
Thanks for any clarification to fix this.

Karaf unresolved constraint in bundle : !(version>=1.0.0)

I just added a new dependencie in my tata-core-provider-servlets pom.xml : "io.jsonwebtoken" in version "0.7.0". I can build my project in Eclipse but when I want to start the bundle in Karaf I have this error:
Error executing command: Error executing command on bundles:
Unable to execute command on bundle 758: Unresolved constraint in bundle tata-core-provider-servlets [758]: Unable to resolve 758.0: missing requirement [758.0] osgi.wiring.package; (&(osgi.wiring.package=io.jsonwebtoken)(version>=0.7.0)(!(version>=1.0.0)))
Is there a restriction in Karaf ? Like no dependencies under 1.0.0 ?
Thanks
Some other library in your bundle require version > 1, I guess.

how to fix missing requirement while the deployment of an OSGI bundle

I am trying to deploy a simple OSGI bundle (hello world) in glassfish 4.1.1 but I got the following error:
Infos: org.osgi.framework.BundleException:
Unresolved constraint in bundle com.mycompany.MavenHelloServiceImpl [324]:
Unable to resolve 324.0: missing requirement [324.0]
osgi.wiring.package; (osgi.wiring.package=com.mycompany.mavenhelloserviceapi)
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
I don't know how to fix the missing package , I already defined "com.mycompany.mavenhelloserviceapi" as a dependency in the bundle MavenHelloServiceImpl and it is present in the dependencies folder in the bundle MavenHelloServiceImpl
Any idea how to fix this error ?!
Having com.mycompany.mavenhelloserviceapi as a dependency in your pom.xml is not enough : the pom is about compile-time dependencies. you see here an issue about a runtime dependency missing.
You should install com.mycompany.mavenhelloserviceapi in your container.
You should modify the project that contains com.mycompany.mavenhelloserviceapi as a bundle project and explicitly export this package. now deploy this bundle alongwith your hello world bundle.
Alternatively ,you can use Pax Wrap to deploy the jar that contains com.mycompany.mavenhelloserviceapi to glassfish without modifying the project.

Installing hibernate bundle in AEM OSGI

I got hibernate jar as osgi bundle from -http://mvnrepository.com/artifact/org.hibernate/hibernate-osgi.
When I installed it in fresh AEM 6.1 , I got the following error -
Unresolved constraint in bundle org.hibernate.osgi [448]: Unable to resolve 448.0: missing requirement [448.0] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)))
org.osgi.framework.BundleException: Unresolved constraint in bundle org.hibernate.osgi [448]: Unable to resolve 448.0: missing requirement [448.0] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:977)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:964)
at org.apache.felix.webconsole.internal.core.InstallHelper.doRun(InstallHelper.java:67)
at org.apache.felix.webconsole.internal.core.BaseUpdateInstallHelper.doRun(BaseUpdateInstallHelper.java:93)
at org.apache.felix.webconsole.internal.core.BaseUpdateInstallHelper.run(BaseUpdateInstallHelper.java:123)
at java.lang.Thread.run(Unknown Source)
04.01.2016 21:43:00.498 *ERROR* [FelixDispatchQueue] org.hibernate.osgi FrameworkEvent ERROR (org.osgi.framework.BundleException: Unresolved constraint in bundle org.hibernate.osgi [448]: Unable to resolve 448.0: missing requirement [448.0] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0))).
Can anyone help ?
The problem is that the persistent API 2.1 is missing. Which means there have to be another bundle which exports the javax.persistence package with version 2.1.

OSGi ( Felix ) extra system.bundle exports

Simple experiment -
bundle A needs some com.sun.xml.internal.bind classes to be available to it via it's class loader ( jaxb.. )
I googled my way to the theoretical solution of forcing system.bundle to export com.sun.xml.internal.bind by adding the package to "org.osgi.framework.system.packages.extra" ( a standard framework parameter implemented in felix, documented at http://felix.apache.org/site/apache-felix-framework-configuration-properties.html ) and importing it in my bundle.
By doing so the bundle would not resolve anymore..
Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=com.sun.xml.internal.bind)
( 5 is the jaxb-using bundle ) Setting "org.osgi.framework.bootdelegation" for "com.sun.xml.internal.bind" and not importing it in the dependent bundle worked as documented.
Am i misinterpreting what system.packages.extra should do? Can i just not resolve imports from system.bundle? I tried explicitly setting system.bundle in the import via bnd at the bottom of my Import-Package directive
com.sun.xml.internal.bind;bundle-symbolic-name="system.bundle",\
*
Which resulted in
Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.xml.internal.bind)(bundle-symbolic-name=system.bundle))
ps: i'm using bnd and the -runproperties to define these. My bndrun file has:
-runproperties: osgi.console.enable.builtin=true,\
com.mycompany.manager.confDir=./etc,\
org.osgi.framework.system.packages.extra=com.sun.xml.internal.bind,\
org.osgi.service.http.port=8888
the bundle that needs jaxb defines the following import
Import-Package: com.sun.xml.internal.bind,\
*
When trying to resolve dependencies in the bndrun editor, i get
Unable to resolve <<INITIAL>> ver=null: missing requirement (osgi.identity=com.mycompany.configuration.jaxb) [caused by: Unable to resolve com.mycompany.configuration.jaxb ver=0.0.0: missing requirement (osgi.wiring.package=com.sun.xml.internal.bind)]
org.osgi.service.resolver.ResolutionException: Unable to resolve <<INITIAL>> ver=null: missing requirement (osgi.identity=com.mycompany.configuration.jaxb) [caused by: Unable to resolve com.mycompany.configuration.jaxb ver=0.0.0: missing requirement (osgi.wiring.package=com.sun.xml.internal.bind)]
at org.apache.felix.resolver.Candidates.populateResource(Candidates.java:285)
at org.apache.felix.resolver.Candidates.populate(Candidates.java:153)
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:148)
at biz.aQute.resolve.ResolveProcess.resolveRequired(ResolveProcess.java:34)
at org.bndtools.core.resolve.ResolveOperation.run(ResolveOperation.java:61)
at org.bndtools.core.resolve.ResolveJob.run(ResolveJob.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
I see you are using Bndtools. Good! We have a special property for setting the system packages from the .bndrun file:
-runsystempackages: com.sun.xml.internal.bind
I'm not sure why it didn't work when you put this inside -runproperties... possibly just a typo though I haven't been able to spot it. Anyway it's better to use -runsystempackages because then the Bndrun resolver also knows to add these packages to the system bundle; then you'll be able to resolve in the bndrun editor as well.

Categories

Resources