Cannot start bundle- missing requirement(osgi.wiring.package)

pres picture pres · Nov 27, 2017 · Viewed 12.2k times · Source

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

Answer

Neil Bartlett picture Neil Bartlett · Nov 27, 2017

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.