2013-10-19 144 views
0

我花了幾天的時間嘗試瞭解如何部署爲OSGI包並需要一些幫助。我使用的是servicemix 4.5.2,maven 3.1.0和maven-bundle-plugin 2.4.0。我在我的.pom中添加了以下標籤OSGI Bundle中缺少需求包 - Felix&Servicemix

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

我的包構建,當我部署到servicemix中時,出現一系列BundleException。我反覆將缺失的軟件包添加到我的pom中,直到我撞到牆上。 「缺少需求包;(package = com.ibm.ejs.ras)」。直接的問題是我找不到ras.jar來下載或在Maven倉庫中。但我認爲更大的問題是我做了不正確的事情,導致我不得不手動追查傳遞性依賴關係。

我已經找到並發現使用Spring和Fuse的預捆綁版本解決了常見問題。 Fuse儲存庫看起來已經消失了,而Spring似乎正在曬黑,並且沒有我需要的所有.jars。我也試過了我在另一篇文章中看到的bundle maven-bundle-plugin,目標已被棄用)。這導致「爲項目org.beanshell生成OSGi捆綁包時出錯:bsh-core:aQute.bnd.osgi.Descriptors $ PackageRef不能轉換爲java.lang.String」。

我已經使用servicemix和camel之前的(pre-OSGI)版本,並且對這兩種產品都非常重視。然而,我正在失去蒸汽(和工作時間),試圖克服OSGI障礙,騾子變得越來越有吸引力。如果有人有一些見解,他們將不勝感激。

謝謝你。

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

+0

你可能不應該打擾在你的包中嵌入春天和駱駝罐。有Karaf和ServiceMix的春天和駱駝功能(雖然可能不適用於Spring 2.0.x)。也就是說,我會添加一個解決方案。 –

回答

0

com.ibm.ejs.ras可能是一個可選的依賴於你在捆綁罈子裏的一個

你會更新您的導入 - 。打包過濾掉違規軟件包。

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

另外:

嵌入依賴性使用引擎蓋下捆綁-類路徑。我希望這個工具的創建者可以這樣做:http://www.aqute.biz/Bnd/FAQ#bundleclasspath

我肯定會同意Embed-Dependency在這種情況下絕對沒有必要,考慮到您使用的ServiceMix具有90%的無論如何,你在這種情況下需要什麼。其餘的可以使用mvn:或wrap:mvn:style-url來安裝在ServiceMix中。 (這是隻有dbcp和lang3和硒)

+0

謝謝你謝娜。 – bottabing

相關問題