OSGi:缺少要求osgi.wiring.package [英] OSGi: Missing requirement osgi.wiring.package

查看:354
本文介绍了OSGi:缺少要求osgi.wiring.package的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个包含5个模块的项目。我使用maven在intellij IDEA中创建它们,然后为所有模块添加OSGi框架支持。我使用maven-bundle-plugin来配置export-package和import-package。但是当我运行它时,总会出现错误:

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).

启动器模块包含Bundle-Activator,而org.gxkl.server包在服务模块中。我使用类似的pom来配置模块,但只有服务模块出错。
启动器中的pom文件如下:

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>


服务中的pom文件如下:

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>

推荐答案

错误消息表示捆绑启动器导入包 org.gxkl.server 但没有捆绑包在导出包的框架中。

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.

顺便说一下,你可以删除< Import-Package> 来自POM的部分。不需要它们。

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

这篇关于OSGi:缺少要求osgi.wiring.package的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆