1

I write a project which contains 5 modules. I create them in intellij IDEA with maven, then add "OSGi" framework support to all the modules. I use maven-bundle-plugin to configure the export-package and import-package. But when I run it, there's always a error:

org.osgi.framework.BundleException: Unable to resolve org.gxkl.launcher [12]  (R 12.0): missing requirement [org.gxkl.launcher [12](R 12.0)]    osgi.wiring.package; (osgi.wiring.package=org.gxkl.server).

The launcher module contains Bundle-Activator, and the org.gxkl.server package is in the service module. I use the similar pom to configure the modules, but only the service module goes wrong. the pom file in launcher is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0     http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>${parent.artifactId}</artifactId>
    <groupId>${parent.groupId}</groupId>
    <version>${parent.version}</version>
</parent>
<modelVersion>${model.version}</modelVersion>

<artifactId>launcher</artifactId>

<packaging>bundle</packaging>

<dependencies>
    ...
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>service</artifactId>
        <version>${project.version}</version>
    </dependency>
    ...
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-Activator>org.gxkl.Starter</Bundle-Activator>
                    <Export-Package>
                        org.gxkl
                    </Export-Package>
                    <Import-Package>
                    <!--some packages in other modules. They work fine-->
                        ...
                        org.gxkl.server <!--packge in service modules. It doesn't work fine-->
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

the pom file in service is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>${parent.artifactId}</artifactId>
    <groupId>${parent.groupId}</groupId>
    <version>${parent.version}</version>
</parent>
<modelVersion>${model.version}</modelVersion>

<artifactId>service</artifactId>

<packaging>bundle</packaging>

<description>...</description>

<dependencies>
    ...
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Export-Package>
                        org.gxkl.server,
                        ...
                    </Export-Package>
                    <Import-Package>
                        ...
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

Qshbx
  • 51
  • 1
  • 6

1 Answers1

2

The error message means that the bundle launcher imports package org.gxkl.server but there is no bundle in the framework that exports the package.

By the way, you can remove the <Import-Package> sections from your POMs. They are not needed.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
  • I'm sorry to reply you so late. As you can see in the pom file of `service` , I export the `org.gxkl.server`. But why it doesn't work in this module? – Qshbx Nov 24 '15 at 13:10
  • I don't know. The POM is a build-time construct, so anything could have happened during build and deployment. I really need to see the MANIFEST.MF of the actual bundle. – Neil Bartlett Nov 24 '15 at 14:23
  • Well, you said that itβ€˜s because there is no bundle in the framework that exports the package before. So I re-checked the settings, and I find that I made a mistake in the setting of felix, so that felix can't find the `service` bundle when running. Now, my project works fine and thank you. – Qshbx Nov 27 '15 at 08:19