【问题标题】:Package-Resolution (Import-Export) problem in maven2 generated osgi-bundles running in ServiceMixmaven2 生成的在 ServiceMix 中运行的 osgi-bundle 中的 Package-Resolution (Import-Export) 问题
【发布时间】:2011-04-10 16:53:39
【问题描述】:

我在 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>

当我尝试激活第二个捆绑包时,我在来自 ServiceMix 的 Karaf 控制台上收到以下错误:

Error executing command: Unresolved constraint in bundle message [233]: package;(package=de.samba.common.message.model)

我还尝试使用 de.samba.common 作为导入和导出,以及每个单独的包声明。我没有得到什么?如何让第二个包看到第一个包中的类?

【问题讨论】:

    标签: osgi maven-2 apache-felix apache-servicemix


    【解决方案1】:

    如果您有父 pom.xml,请尝试使用它进行构建。即使正确提到了导入导出声明,仅构建子 pom 似乎也无法解决依赖关系。

    【讨论】:

      【解决方案2】:

      查看(或粘贴)生成的 MANIFEST 文件(您可以为此在 ServiceMix 中使用 'headers:[id]')。你的第一个包真的导出了包“de.samba.common.message.model”吗?

      【讨论】:

      • 这是一个获得很多观点的问题,因此,如果你们中的任何人找到了解决方案,您仍然应该在此处发布您所做的 - 如果有帮助,它将获得支持。
      猜你喜欢
      • 1970-01-01
      • 2017-09-26
      • 2018-06-04
      • 2014-11-01
      • 2011-06-18
      • 1970-01-01
      • 2017-06-11
      • 2011-10-06
      • 2013-10-28
      相关资源
      最近更新 更多