2

I am new to Apache karaf and OSGI. I am trying to write and run a very simple bundle. But I am getting this error while starting that bundle:

Error executing command: Error executing command on bundles: Unable to resolve karaf [86](R 86.0): missing requirement [karaf [86](R 86.0)] osgi.wiring.package; (osgi.wiring.package=bundle) Unresolved requirements: [[karaf [86](R 86.0)] osgi.wiring.package; (osgi.wiring.package=bundle)]

My pom is: 4.0.0

<groupId>com</groupId>
<artifactId>karaf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>

<name>karaf Bundle</name>
<description>
    karaf OSGi bundle project.
</description>

<properties>
    <maven-bundle-plugin.version>2.5.4</maven-bundle-plugin.version>
    <osgi.version>6.0.0</osgi.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>${osgi.version}</version>

        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>${maven-bundle-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Version>${project.version}</Bundle-Version>
                    <Bundle-Activator>bundle.Activator</Bundle-Activator>
                    <Export-Package>
                        bundle*;version=${project.version}
                    </Export-Package>
                    <Import-Package>
                         org.osgi.framework,*
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

My manifest.mf file is here.

> Manifest-Version: 1.0
Bnd-LastModified: 1394131053386
Bundle-Copyright: Copyright (c) OSGi Alliance (2000, 2014). All Rights R
 eserved.
Bundle-Description: OSGi Core Release 6, Interfaces and Classes for use 
 in compiling bundles.
Bundle-License: http://opensource.org/licenses/apache2.0.php; link="http
 ://www.apache.org/licenses/LICENSE-2.0"; description="Apache License, V
 ersion 2.0"
Bundle-ManifestVersion: 2
Bundle-Name: osgi.core
Bundle-SymbolicName: osgi.core
Bundle-Vendor: OSGi Alliance
Bundle-Version: 6.0.0.201403061837
Created-By: 1.6.0_45 (Sun Microsystems Inc.)
DynamicImport-Package: *
Export-Package: org.osgi.dto;version="1.0",org.osgi.resource;version="1.
 0",org.osgi.resource.dto;version="1.0";uses:="org.osgi.dto",org.osgi.fr
 amework;version="1.8",org.osgi.framework.dto;version="1.8";uses:="org.o
 sgi.dto",org.osgi.framework.hooks.bundle;version="1.1";uses:="org.osgi.
 framework",org.osgi.framework.hooks.resolver;version="1.0";uses:="org.o
 sgi.framework.wiring",org.osgi.framework.hooks.service;version="1.1";us
 es:="org.osgi.framework",org.osgi.framework.hooks.weaving;version="1.1"
 ;uses:="org.osgi.framework.wiring",org.osgi.framework.launch;version="1
 .2";uses:="org.osgi.framework",org.osgi.framework.namespace;version="1.
 1";uses:="org.osgi.resource",org.osgi.framework.startlevel;version="1.0
 ";uses:="org.osgi.framework",org.osgi.framework.startlevel.dto;version=
 "1.0";uses:="org.osgi.dto",org.osgi.framework.wiring;version="1.2";uses
 :="org.osgi.framework,org.osgi.resource",org.osgi.framework.wiring.dto;
 version="1.2";uses:="org.osgi.dto,org.osgi.resource.dto",org.osgi.servi
 ce.condpermadmin;version="1.1.1";uses:="org.osgi.framework,org.osgi.ser
 vice.permissionadmin",org.osgi.service.packageadmin;version="1.2";uses:
 ="org.osgi.framework",org.osgi.service.permissionadmin;version="1.2",or
 g.osgi.service.startlevel;version="1.1";uses:="org.osgi.framework",org.
 osgi.service.url;version="1.0",org.osgi.util.tracker;version="1.5.1";us
 es:="org.osgi.framework"
Import-Package: javax.security.auth.x500;resolution:=optional
Tool: Bnd-2.2.0.20130927-173453
pres
  • 105
  • 1
  • 2
  • 9
  • 1
    Could [this](https://stackoverflow.com/questions/30480508/karaf-maven-unable-to-resolve-missing-requirement-osgi-wiring-package) help? – pirho Nov 27 '17 at 10:25

1 Answers1

10

Let's break this down: "Missing requirement" simply means that your bundle has been installed into the OSGi Framework but it has a requirement that could not be satisfied by any of the other bundles that are installed.

The unresolved requirement is in the namespace osgi.wiring.package, which means that the kind of requirement is a Java package import, i.e. what you see as an Import-Package in your bundle's manifest. In other words, your bundle imports a package and no other bundle exports that package.

Finally the bit at the end, (osgi.wiring.package=bundle), is a filter which expresses the exact package name that your bundle requires. In this case your bundle apparently imports a package named "bundle".

That is a little odd, and implies that you have probably made a mistake in the way your bundle is built. It would help if you post the details about how you built this bundle.

Neil Bartlett
  • 23,027
  • 3
  • 39
  • 74
  • Hi neil, I have added my pom.xml details. But in my org.osgi jar file , I have the osgi.framework.wiring package. So, any idea why it is giving an error that its missing? – pres Nov 27 '17 at 12:17
  • You have posted the manifest of osgi.core-6.0.0.jar, not your own bundle. Also why are you exporting a package named "bundle"?? Do you have a package called "bundle" in your Java source code? This is all very difficult to understand, I think you need to step back and tell us what you're actually trying to do. – Neil Bartlett Nov 27 '17 at 12:57
  • 1
    @pres Downvoting your question because you seem to have [lost interest in solving it](http://idownvotedbecau.se/beingunresponsive). – Neil Bartlett Dec 05 '17 at 08:15
  • Thank you for the detailed explanation. After I fixed my POM I did a Maven "clean" and then a Maven "package" to ensure plugins weren't adding the entry into my manifest file. – Osmund Francis Oct 31 '18 at 05:55
  • Check the build in the pom. The problem I had was that the entry for the Bundle-Activator was wrong and the Export-Package was wrong. – Richard K. Campion Jun 28 '19 at 03:31