【问题标题】:Missing requirement package in OSGI Bundle - Felix & ServicemixOSGI Bundle 中缺少需求包 - Felix 和 Servicemix
【发布时间】:2013-10-28 14:26:54
【问题描述】:

我花了几天时间试图了解如何部署为 OSGI 包并需要一些帮助。我正在使用 servicemix 4.5.2、maven 3.1.0 和 maven-bundle-plugin 2.4.0。我在我的 .pom 中添加了以下标签

<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>    
<Embed-Transitive>true</Embed-Transitive>

我的包构建,当我部署到 servicemix 中时,我得到了一系列 BundleExceptions。我反复将丢失的包添加到我的 pom 中,直到遇到问题。 “缺少需求包;(package=com.ibm.ejs.ras)”。直接的问题是我找不到要下载的 ras.jar 或在 Maven 存储库中。但我认为更大的问题是我做错了一些事情,导致我不得不手动追踪传递依赖。

我进行了深入研究,发现使用 Spring 和 Fuse 的预捆绑版本解决了常见问题。 Fuse 存储库似乎已经消失,而 Spring 存储库似乎正在日落,并且没有我需要的所有 .jar。我还尝试了我在另一篇文章中看到的 bundleall maven-bundle-plugin,目标现在已被弃用)。这导致“为项目 org.beanshell:bsh-core:aQute.bnd.osgi.Descriptors$PackageRef 无法转换为 java.lang.String 生成 OSGi 包时出错”。

我使用过之前(OSGI 之前)版本的 servicemix 和 camel,并且对这两种产品都非常重视。然而,为了克服 OSGI 障碍,我正在失去动力(和工作时间),而 Mule 变得越来越有吸引力。如果有人有一些见解,他们将不胜感激。

谢谢。

我的 pom:

<?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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.mycompany.abc</groupId>
    <artifactId>core</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>myartifact</artifactId>
<packaging>bundle</packaging>
<name>myartifact</name>

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${camel.version}</version>         
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-mail</artifactId>
        <version>${camel.version}</version> 
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-dao</artifactId>
        <version>2.0.8</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
        <scope>compile</scope>
    </dependency> 
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.35.0</version>
    </dependency>           
</dependencies>

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.4.0</version>    
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Bundle-Description>${project.description}</Bundle-Description>
            <Export-Package>com.mycompany.abc.myartifact</Export-Package>
            <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>    
            <Embed-Transitive>true</Embed-Transitive>
          </instructions>
        </configuration>
      </plugin>
    </plugins>          
</build>

【问题讨论】:

  • 你可能不应该在你的包中嵌入 spring 和 camel jars。 Karaf 和 ServiceMix 有 spring 和 camel 特性(虽然可能不是 Spring 2.0.x)。也就是说,我将添加一个解决方案。

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


【解决方案1】:

com.ibm.ejs.ras 可能是您捆绑的其中一个 JARS 的可选依赖项。

您将更新您的 Import-Package 以过滤掉有问题的包。

<Import-Package>!com.ibm.ejs.ras, *</Import-Package>.

还有:

Embed-Dependency 在后台使用 Bundle-Classpath。我会听从使您能够执行此操作的工具的创建者:http://www.aqute.biz/Bnd/FAQ#bundleclasspath

我绝对同意在这种情况下嵌入依赖绝对不是必需的,考虑到您使用的是 ServiceMix,无论如何,它提供了您在这种情况下所需的 90%。其余的可以使用 mvn: 或 wrap:mvn: style-urls 安装在 ServiceMix 中。 (只有 dbcp 和 lang3 和 selenium)

【讨论】:

    猜你喜欢
    • 2012-03-06
    • 1970-01-01
    • 2019-05-29
    • 2012-01-11
    • 2014-11-01
    • 2013-03-23
    • 2013-01-31
    • 2014-01-22
    • 2016-02-18
    相关资源
    最近更新 更多