私は現在、OSGi、iPOJO、および iPOJO アノテーションから始めて、Felix にデプロイされる単純なコンポーネントを構築しようとしています。残念ながら、次のような、解決するのに何時間もかかる、または何時間も無駄にした後に解決することさえできないさまざまな問題に出くわしています。
Maven を使用して構築した OSGi バンドル内の既存のライブラリを使用したいと考えています。ライブラリは現在「OSGI 化」されておらず、中期的にそうする予定はありません。そのため、…を使用して、このライブラリとそのすべての依存関係をバンドルに含めたいと思います。
<Embed-Dependency>*</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
私が今持っているのは、OSGi コンポーネントの次の pom.xml ファイルです。
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>samplecomponent</artifactId>
<packaging>bundle</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<encoding>UTF-8</encoding>
</compilerArguments>
<showDeprecation>true</showDeprecation>
<verbose>true</verbose>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.6</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Embed-Dependency>*</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>lib</Embed-Directory>
<Export-Package>*</Export-Package>
<_exportcontents>*</_exportcontents>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.annotations</artifactId>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>foo</groupId>
<artifactId>mylibrary</artifactId>
<version>1.2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
バンドル jar ファイルは問題なくビルドされますが、バンドルを Apache Felix にデプロイして開始すると、次のエラーが発生します。
g! install file:/…/samplecomponent-0.0.1-SNAPSHOT.jar
Bundle ID: 8
g! start 8
org.osgi.framework.BundleException: Unresolved constraint in bundle samplecomponent [8]: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package; (osgi.wiring.package=com.sun.jdmk.comm)
ログレベルを最高の詳細度に設定しましたが、残念ながらこれ以上の情報はありません。mylibrary を削除すると、バンドルは問題なく開始されます。
どんな提案でも大歓迎です!