Java 无法解决 1.0:缺少需求 [1.0] osgi.wiring.package;(&(osgi.wiring.package=

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18415375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:25:17  来源:igfitidea点击:

Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=

javaosgiapache-felixosgi-bundle

提问by AKIWEB

I am trying to start one of my bundles, but as soon as I start it, I get the below exception. I am not sure what the problem is.

我正在尝试启动我的一个包,但是一旦我启动它,我就会收到以下异常。我不确定问题是什么。

org.osgi.framework.BundleException: Unresolved constraint in bundle GoldeneyeModellingFramework [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.host.domain.sharedpersonalize.storageservice)(version>=1.0.0)(!(version>=2.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.BundleImpl.start(BundleImpl.java:955)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
    at com.host.personalize.bullseye.InitializeOSGiFramework.installAndStartBundle(InitializeOSGiFramework.java:217)
    at com.host.personalize.bullseye.InitializeOSGiFramework.getBundlesInformation(InitializeOSGiFramework.java:167)
    at com.host.personalize.bullseye.InitializeOSGiFramework.run(InitializeOSGiFramework.java:92)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:328)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:161)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(ScheduledThreadPoolExecutor.java:109)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:192)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:216)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)

Let me tell you how I am doing it- I have launched an OSGi framework by following this tutorialand it works fine, but as soon as I start the bundle, GoldeneyeModellingFramework-

让我告诉你我是如何做的 - 我已经按照本教程启动了一个 OSGi 框架,它运行良好,但是一旦我启动了这个包,GoldeneyeModellingFramework -

    for (Bundle bundle : installedBundles) {
        bundle.start();
    }

And, I am using the dependency below in my main project which launches an OSGi framework/container:

而且,我在启动 OSGi 框架/容器的主项目中使用了以下依赖项:

<dependency>
    <groupId>org.apache.felix</groupId>
    <artifactId>org.apache.felix.framework</artifactId>
    <version>4.2.1</version>
</dependency>
<dependency>
    <groupId>org.ops4j.pax.url</groupId>
    <artifactId>pax-url-mvn</artifactId>
    <version>1.3.6</version>
</dependency>

It always give me the above exception. The Bundle GoldeneyeModellingFrameworkdepends on the maven project GoldeneyeStorageServicewhich includes this package com.host.domain.sharedpersonalize.storageservice.

它总是给我上述例外。BundleGoldeneyeModellingFramework依赖于GoldeneyeStorageService包含这个包的 maven 项目com.host.domain.sharedpersonalize.storageservice

Below is the Manifest.MFfile for GoldenModellingFrameworkbundle:

下面是包的Manifest.MF文件GoldenModellingFramework

Manifest-Version: 1.0
Bnd-LastModified: 1377298131182
Build-Jdk: 1.6.0_26
Built-By: rjamal
Bundle-Activator: com.host.personalize.goldeneye.framework.activator.Activator
Bundle-Description: Managed dependencies and plugins across all Raptor applications.
Bundle-ManifestVersion: 2
Bundle-Name: GoldeneyeModellingFramework
Bundle-SymbolicName: GoldeneyeModellingFramework
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: com.host.personalize.goldeneye.framework.activator;us
 es:="org.osgi.framework,com.host.personalize.goldeneye.modelling.fra
 mework,org.osgi.util.tracker";version="1.0.0",com.host.personalize.
 goldeneye.modelling.framework;uses:="com.host.soaframework.common.except
 ions,org.osgi.framework,com.host.domain.sharedpersonalize.storagese
 rvice";version="1.0.0"
Import-Package: com.host.domain.sharedpersonalize.storageservice;ver
 sion="[1.0,2)",com.host.soaframework.common.exceptions;version="[1.4,2)
 ",org.osgi.framework;version="[1.6,2)",org.osgi.util.tracker;version="[
 1.5,2)"
Originally-Created-By: Apache Maven Bundle Plugin
ServicesURLStrategyVersion: 1.0.0-RELEASE
Tool: Bnd-1.50.0
X-Raptor-Source-Dir: S:\GitViews\GoldeneyeStream\GoldeneyeModellingFram
 ework/src/main/webapp,S:\GitViews\GoldeneyeStream\GoldeneyeModellingFr
 amework/src/main/resources,S:\GitViews\GoldeneyeStream\GoldeneyeModell
 ingFramework

And, below is the pom.xmlfile for GoldeneyeModellingFrameworkbundle:

而且,下面是捆绑pom.xml文件GoldeneyeModellingFramework

<?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">

    <!-- POM Information about the Project -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.host.personalize.goldeneye.modelling.framework</groupId>
    <artifactId>GoldeneyeModellingFramework</artifactId>
    <version>1.0.0</version>
    <!-- Packing Type is bundle for OSGI Library Bundle -->
    <packaging>bundle</packaging>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.3.0</version><!--$NO-MVN-MAN-VER$ -->
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <version>4.3.0</version><!--$NO-MVN-MAN-VER$ -->
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.host.personalize.goldeneye</groupId>
            <artifactId>GoldeneyeStorageService</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

    <!-- Build Configration -->
    <build>
        <plugins>
            <!-- Apache Felix Bundle Plugin - For Generation of Manifest after Compile 
                phase -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <!-- Configuration for generating the Manifest.mf -->
                <configuration>
                    <manifestLocation>src/main/resources/META-INF</manifestLocation>
                    <!-- Manifest Headers which need to customized during manifest generation -->
                    <instructions>
                        <Bundle-SymbolicName>GoldeneyeModellingFramework</Bundle-SymbolicName>
                        <Bundle-Activator>com.host.personalize.goldeneye.framework.activator.Activator</Bundle-Activator>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- Configuration of repositories for dependency resolution -->
    <repositories>
        <!-- Raptor Bundles Repository -->
        <!-- This is needed to locate the Raptor Parent project. Other repositories 
            come from the parent. -->
        <repository>
            <id>releases</id>
            <url>http://nxraptor/content/repositories/releases/</url>
            <releases>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>thirdparty</id>
            <url>http://nxraptor/content/repositories/thirdparty/</url>
            <releases>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

Let me know if you need any other files for GoldeneyeStorageServicemaven project. I am not sure how to fix this problem. Can anyone help me with this?

如果您需要GoldeneyeStorageServiceMaven 项目的任何其他文件,请告诉我。我不知道如何解决这个问题。谁能帮我这个?

Some Update:-

一些更新:-

Below is the MANIFEST.MF file for GoldeneyeStorageServiceproject-

以下是GoldeneyeStorageService项目的 MANIFEST.MF 文件-

Manifest-Version: 1.0
Bnd-LastModified: 1377333824248
Build-Jdk: 1.6.0_26
Built-By: rjamal
Bundle-Description: Managed dependencies and plugins across all Raptor a
 pplications.
Bundle-ManifestVersion: 2
Bundle-Name: GoldenlseyeStorageService
Bundle-SymbolicName: GoldenlseyeStorageService
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: com.host.domain.sharedpersonalize.storageservice;use
 s:="com.host.soaframework.common.exceptions,com.host.marketplace.servic
 es.storageservice,com.host.personalize.services.storage.consumer.ge
 n,com.host.personalize.services.storage.consumer,com.host.soaframew
 ork.sif.service,com.host.marketplace.services,com.host.kernel.logger";v
 ersion="1.0.0",com.host.marketplace.services.storageservice;uses:="java
 x.xml.bind.annotation,com.host.marketplace.services,javax.activation";v
 ersion="1.0.0",com.host.personalize.services.storage.consumer;uses:
 ="javax.xml.ws,com.host.marketplace.services.storageservice";version="1
 .0.0",com.host.personalize.services.storage.consumer.gen;uses:="com
 .host.soaframework.common.exceptions,com.host.personalize.services.
 storage.consumer,com.host.soaframework.sif.impl.internal.service,com.eb
 ay.soaframework.sif.service,javax.xml.ws,com.host.marketplace.services.
 storageservice,com.host.soaframework.common.types,com.host.soaframework
 .common.impl.internal.schema,javax.xml.namespace,com.host.soaframework.
 common.registration";version="1.0.0"
Import-Package: com.host.kernel.logger;version="[1.19,2)",com.host.marke
 tplace.services;version="[1.7,2)",com.host.soaframework.common.exceptio
 ns;version="[1.4,2)",com.host.soaframework.common.impl.internal.schema;
 version="[1.4,2)",com.host.soaframework.common.registration;version="[1
 .4,2)",com.host.soaframework.common.types;version="[1.4,2)",com.host.so
 aframework.sif.impl.internal.service;version="[1.4,2)",com.host.soafram
 ework.sif.service;version="[1.4,2)",javax.activation,javax.xml.bind.ann
 otation,javax.xml.namespace,javax.xml.ws
ServicesURLStrategyVersion: 1.0.0-RELEASE
Tool: Bnd-1.50.0
X-Raptor-Source-Dir: S:\GitViews\GoldenlseyeStream\GoldenlseyeStorageServic
 e/src/main/webapp,S:\GitViews\GoldenlseyeStream\GoldenlseyeStorageService/
 src/main/resources,S:\GitViews\GoldenlseyeStream\GoldenlseyeStorageService

采纳答案by Neil Bartlett

The error message means that your bundle GoldeneyeModellingFrameworkimports the package com.host.domain.sharedpersonalize.storageservicebut no bundle exports that package. Therefore the import cannot be resolved.

该错误消息意味着您的包GoldeneyeModellingFramework导入了该包,com.host.domain.sharedpersonalize.storageservice但没有包导出该包。因此无法解析导入。

You said that bundle GoldeneyeStorageService"includes" that package, but what does "includes" mean?? You need this package to be exported, i.e. listed in the Export-Packageheader. If the package is included in that bundle but not exported, then it is a private package that cannot be imported by any other bundle.

你说捆绑包GoldeneyeStorageService“包括”那个包,但“包括”是什么意思?您需要导出此包,即在Export-Package标题中列出。如果该包包含在该包中但未导出,则它是一个私有包,不能被任何其他包导入。