在OSGI Bundle中缺少需求包 - Felix& ServiceMix的

时间:2013-10-19 22:16:59

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

我花了几天时间试图了解如何部署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看起来像是太阳落山,并没有我需要的所有.jars。我也试过了bundleall maven-bundle-plugin,我在另一篇文章中看到了目标现已弃用)。这导致“为项目org.beanshell生成OSGi包时出错:bsh-core:aQute.bnd.osgi.Descriptors $ PackageRef无法转换为java.lang.String”。

我使用过servicemix和camel之前的(OSGI之前)版本,并且对这两种产品都非常重视。然而,我正试图克服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>

1 个答案:

答案 0 :(得分:0)

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

我绝对同意在这种情况下绝对没有必要使用Embed-Dependency,考虑到你使用的是ServiceMix,无论如何它都是你需要的90%。其余的可以使用mvn:或wrap:mvn:style-urls安装在ServiceMix中。 (只有dbcp和lang3和selenium)