我有一個簡單的OSGi包寫入,這裏是源文件。當我將它安裝在equinox OSGi容器中時,它不會自動解決它。有人可以解釋我在這裏做錯了嗎?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 [email protected]
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)
添加清單數據。它處於安裝狀態。當使用「diag」命令時,它說沒有沒有未解決的約束。 –
這不是必要的,但要排除故障,您可以添加一個Bundle-Activator並查看是否啓動了啓動。 – Anshuman
我試着在我的機器上運行你的例子(我使用Karaf,2.4.0的bundle-plugin),它工作正常:87 |活動| 80 | 1.0.0 | sample-api – Anshuman