[英]How to setup an Eclipse Project with multiple Subprojects (OSGi-Bundles)
[英]Package-Resolution (Import-Export) problem in maven2 generated osgi-bundles running in ServiceMix
我在pom.xml中使用以下配置进行捆绑:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<osgiManifest>
<bundleName>SAMBA Common</bundleName>
<bundleDescription>The Common shared resources</bundleDescription>
<bundleActivator>de.samba.common.Activator</bundleActivator>
<importPackage>
org.osgi.framework,
org.dcm4che.*;version=2.0.22;-split-package:=merge-first
</importPackage>
<exportPackage>
de.samba.common.*
</exportPackage>
<bundleVendor>SAMBA Framework</bundleVendor>
</osgiManifest>
<instructions>
<Bundle-Activator>de.samba.common.Activator</Bundle-Activator>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>1.0.0</Bundle-Version>
<Import-Package>
org.osgi.framework,
org.dcm4che.*;version=2.0.22;-split-package:=merge-first
</Import-Package>
<Export-Package>
de.samba.common.*
</Export-Package>
<Private-Package>
</Private-Package>
<Require-Bundle>org.apache.cxf.bundle
</Require-Bundle>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
当我将其部署到ServiceMix(我的OSGi容器)时,它可以工作并被激活。 在我的另一个OSGi捆绑软件中,我尝试使用在上部捆绑软件中定义的类。 配置看起来像这样:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<osgiManifest>
<bundleName>SAMBA Message</bundleName>
<bundleDescription>The Message WebService</bundleDescription>
<bundleActivator>de.samba.message.Activator</bundleActivator>
<bundleVendor>SAMBA</bundleVendor>
<importPackage>de.samba.common.*</importPackage>
</osgiManifest>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
javax.jws,
javax.wsdl,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.namespace,
javax.xml.ws,
META-INF.cxf,
META-INF.cxf.osgi,
org.apache.cxf.bus,
org.apache.cxf.bus.spring,
org.apache.cxf.bus.resource,
org.apache.cxf.configuration.spring,
org.apache.cxf.resource,
org.apache.cxf.jaxws,
org.apache.cxf.transport.http_osgi,
org.springframework.beans.factory.config,
org.osgi.framework,
de.samba.common.*
</Import-Package>
<Private-Package>
</Private-Package>
<Require-Bundle>
</Require-Bundle>
<!-- DynamicImport-Package>*</DynamicImport-Package-->
</instructions>
</configuration>
</plugin>
当我尝试激活第二个捆绑软件时,在Karaf控制台上从ServiceMix收到以下错误:
Error executing command: Unresolved constraint in bundle message [233]: package;(package=de.samba.common.message.model)
我还尝试将de.samba.common用作导入和导出,以及每个包的声明。 我什么没来? 如何使第二个捆绑包看到第一个捆绑包中的类?
查看(或粘贴)生成的MANIFEST文件(您可以在ServiceMix中使用“ headers:[id]”)。 软件包“ de.samba.common.message.model”是否确实由您的第一个捆绑包导出?
如果您有一个父pom.xml,请尝试使用它进行构建。 即使仅正确提及import export声明,仅构建子poms似乎也无法解决依赖关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.