2012-01-04 40 views
1

我使用ServiceMix 3.5 我有多個ServiceAssemblies,每個ServiceUnit。 服務單位有許多共同的圖書館,所以我在maven pom中用'提供'範圍標記它們。 共享庫包含我想要服務單元共享的所有庫。 我根據以下Maven pom.xml中的內置,但效果是一個簡單的異常:如何使用jbi-maven-plugin集成servicemix共享庫?

拋出java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource類加載器 org.apache.xbean。 spring.context.FileSystemXmlApplicationContext

我可以做什麼(可能使用jbi-maven-plugin)以便我的服務單元使用共享庫中的jar?

共享庫服務單元POM:

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>SHARED_SU</artifactId> 
    <packaging>jbi-service-unit</packaging> 
    <version>0.0.1-SNAPSHOT</version> 

    <parent> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>theParent</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
    </parent> 

    <build> 
    <defaultGoal>install</defaultGoal> 
    <plugins/> 
    </build> 

    <properties><componentName>servicemix-camel</componentName></properties> 

    <dependencies> 
    ... 
    </dependencies> 
</project> 

共享庫服務單元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> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>SHARED_SA</artifactId> 
    <packaging>jbi-shared-library</packaging> 
    <version>0.0.1-SNAPSHOT</version> 

    <parent> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>theParent</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
    </parent> 

    <dependencies> 
    <dependency> 
     <groupId>aaa.bbb</groupId> 
     <artifactId>SHARED_SU</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    </dependencies> 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.servicemix.tooling</groupId> 
     <artifactId>jbi-maven-plugin</artifactId> 
     <version>3.2.3</version> 
     <extensions>true</extensions> 
     <configuration> 
      <type>service-assembly</type> 
      <classLoaderDelegation>parent-first</classLoaderDelegation> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

需要使用的共享庫的服務單元的聚甲醛:

<?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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>theServiceUnit</artifactId> 
    <packaging>jbi-service-unit</packaging> 
    <version>0.0.1-SNAPSHOT</version> 

    <parent> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>theParent</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
    </parent> 

    <build> 
    <defaultGoal>install</defaultGoal> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.servicemix.tooling</groupId> 
     <artifactId>jbi-maven-plugin</artifactId> 
     <version>3.2.3</version> 
     <extensions>true</extensions> 
     </plugin> 
    </plugins> 
    </build> 
    <dependencies> 
    ... <!-- all "PROVIDED" in scope--> 
    <properties> 
    <componentName>servicemix-camel</componentName> 
    </properties> 
</project> 

爲服務單元

<?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> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>theServiceAssembly</artifactId> 
    <packaging>jbi-service-assembly</packaging> 
    <version>0.0.1-SNAPSHOT</version> 

    <parent> 
    <groupId>aaa.bbb</groupId> 
    <artifactId>theParent</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
    </parent> 

    <dependencies> 
    <dependency> 
     <groupId>aaa.bbb</groupId> 
     <artifactId>theServiceUnit</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    </dependencies> 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.servicemix.tooling</groupId> 
     <artifactId>jbi-maven-plugin</artifactId> 
     <version>3.2.3</version> 
     <extensions>true</extensions> 
     <configuration> 
      <type>service-assembly</type> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

回答

0

服務集合的出海我想你誤會JBI組件/ SharedLib/SA/SU或JBI是如何工作的類加載器的一些概念,請大家看看here得到更多細節。

我不明白「共享庫服務單元pom」是什麼意思,按照JBI規範,SharedLib不應該有任何服務單元,它只是由JBI組件引用,如servicemix-camel,所有servicemix JBI組件僅引用一個名稱爲servicemix-shared的默認SharedLib。

類org.apache.commons.dbcp.BasicDataSource是公地dbcp.jar但公地dbcp.jar不在smx3.x默認sharedlib ServiceMix的共享 - $ {}版本-installer.zip ,所以這意味着默認情況下,除非您在SU的xbean.xml中明確添加,否則所有servicemix-camel su都不能看到此類。