开发者

Package-Resolution (Import-Export) problem in maven2 generated osgi-bundles running in ServiceMix

开发者 https://www.devze.com 2023-01-15 20:45 出处:网络
I have one bundle using the following configuration in pom.xml: <plugin> <groupId>org.apache.felix</groupId>

I have one bundle using the following configuration in 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>

This works and gets activated when I deploy it to ServiceMix (my OSGi container). In another OSGi bundle of mine, I try to use classes that are defined in the upper bundle. The config looks like this:

<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,
        o开发者_如何学JAVArg.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>

When I try to activate this second bundle, I get the following error on the Karaf Console from ServiceMix:

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

I also tried using de.samba.common as import and export, and also every single package declaration. What didn't I get here? How can I make the 2nd bundle see the classes from the first bundle?


Have a look at (or paste) the generated MANIFEST files (you can use 'headers:[id]' in ServiceMix for this). Is package 'de.samba.common.message.model' realy exported by your first bundle?


In case you have a parent pom.xml, try building using that. Building only child poms doesnt seem to resolve the dependencies, even if the import export declarations are correctly mentioned.

0

精彩评论

暂无评论...
验证码 换一张
取 消