OSGi Bundle无法自动解决

问题描述 投票:0回答:3

我写了一个简单的OSGi包,这里是源文件。当我在equinox OSGi容器中安装它时,它不会自动解决它。谁能解释我在这里做错了什么?

package org.sample.api;

/**
* Created on 3/11/14.
*/
public interface Hello {

    void sayHello();
}

这是捆绑包的pom.xml文件。

<?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>osgi</artifactId>
        <groupId>osgi</groupId>
        <version>1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>sample-api</artifactId>
    <version>1.0</version>
    <packaging>bundle</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.5</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Vendor>Sample Inc</Bundle-Vendor>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Export-Package>
                            org.sample.api*;version=1.0.0
                        </Export-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

MANIFEST.MF

Manifest-Version: 1
Bnd-LastModified: 1396602001251
Build-Jdk: 1.6.0_45
Built-By: Zeus
Bundle-ManifestVersion: 2
Bundle-Name: sample-api
Bundle-SymbolicName: sample-api
Bundle-Vendor: Sample Inc
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: org.sample.api;version="1.0.0"
Tool: Bnd-1.43.0

这是捆绑安装控制台输出

    Bundle id is 7
RegisteredServices   null
ServicesInUse        null
LoaderProxy          sample-api; bundle-version="1.0.0"
Fragments            null
ClassLoader          null
Version              1.0.0
LastModified         1396605985751
Headers               Bnd-LastModified = 1396602001251
 Build-Jdk = 1.6.0_45
 Built-By = Zeus
 Bundle-ManifestVersion = 2
 Bundle-Name = sample-api
 Bundle-SymbolicName = sample-api
 Bundle-Vendor = Sample Inc
 Bundle-Version = 1.0.0
 Created-By = Apache Maven Bundle Plugin
 Export-Package = org.sample.api;version="1.0.0"
 Manifest-Version = 1
 Tool = Bnd-1.43.0


BundleContext        null
BundleId             7
StartLevel           1
SymbolicName         sample-api
BundleData           sample-api_1.0.0
KeyHashCode          7
StateChanging        null
BundleDescription    sample-api_1.0.0
Framework            org.eclipse.osgi.framework.internal.core.Framework@65cb687f
ResolutionFailureException org.osgi.framework.BundleException: The bundle "sample-api_1.0.0 [7]" could not be resolved
Revisions            [sample-api_1.0.0]
Key                  7
ProtectionDomain     null
Location             file:/home/Zeus/idea-projects/osgi/sample-api/target/sample-api-1.0.jar
State                2
Bundle                   7|Installed  |    1|sample-api (1.0.0)
java osgi equinox modularity
3个回答
1
投票

请从jar发布生成的MANIFEST.MF。我看不出有什么问题。

如果捆绑未解决,那么它处于什么状态?安装?一个可能的原因可能是容器的某些传递依赖性在容器上不可用。

P.S:您可能希望将最新版本2.4.0用于maven-bundle-plugin。

EDIT1这是我得到的清单:

清单 - 版本:1.0 Bnd-LastModified:1396605817562 Build-Jdk:1.7.0_45 内置:anshuman Bundle-ManifestVersion:2 Bundle-Name:sample-api Bundle-SymbolicName:sample-api Bundle-Vendor:Sample Inc 捆绑版本:1.0.0 创建者:Apache Maven Bundle插件 Export-Package:org.sample.api; version =“1.0.0” 工具:Bnd-2.1.0.20130426-122213

EDIT2我希望您在安装后刷新并启动它。 刷新7 开始7 其中7是您的包ID。


0
投票

看起来您的捆绑包没有Activator,至少您的给定样本不包含一个,并且生成的Manifest的输出不包含Bundle-Activator部分。此时我会说你的捆绑包处于解决状态,因为它无法激活。


0
投票

INSTALLED状态不是错误条件。它只是意味着已经安装了捆绑包,这是真的。

如果您确实看到了实际的错误消息,请提供详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.