Shared libraries 如何使用jbi maven插件集成servicemix共享库?

Shared libraries 如何使用jbi maven插件集成servicemix共享库?,shared-libraries,apache-servicemix,jbi,Shared Libraries,Apache Servicemix,Jbi,我使用ServiceMix3.5 我有多个ServiceAssembly,每个ServiceUnit对应一个ServiceAssembly。 这些服务单元有许多公共库,因此我在maven pom中用作用域“提供”标记它们。 共享库包含我希望服务单元共享的所有库。 我根据以下maven pom.xml构建,但其效果是一个简单的例外: java.lang.ClassNotFoundException: classloader中的org.apache.commons.dbcp.BasicDataSou

我使用ServiceMix3.5 我有多个ServiceAssembly,每个ServiceUnit对应一个ServiceAssembly。 这些服务单元有许多公共库,因此我在maven pom中用作用域“提供”标记它们。 共享库包含我希望服务单元共享的所有库。 我根据以下maven pom.xml构建,但其效果是一个简单的例外:

java.lang.ClassNotFoundException: classloader中的org.apache.commons.dbcp.BasicDataSource org.apache.xbean.spring.context.FileSystemXmlApplicationContext

为了让我的服务单元使用共享库中的jar,我可以做什么(可能使用jbi maven插件)

共享图书馆服务单元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>
<?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>

4.0.0
aaa.bbb
分享苏
jbi服务单位
0.0.1-快照
aaa.bbb
家长
1.0-快照
../pom.xml
安装
servicemix骆驼
...
共享图书馆服务单元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>
<?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>

4.0.0
aaa.bbb
共享的
jbi共享库
0.0.1-快照
aaa.bbb
家长
1.0-快照
../pom.xml
aaa.bbb
分享苏
0.0.1-快照
org.apache.servicemix.tooling
jbi maven插件
3.2.3
真的
服务组合
家长优先
需要使用共享库的服务单元的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>
<?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>

4.0.0
aaa.bbb
服务单位
jbi服务单位
0.0.1-快照
aaa.bbb
家长
1.0-快照
../pom.xml
安装
org.apache.servicemix.tooling
jbi maven插件
3.2.3
真的
... 
servicemix骆驼
维修单元维修组件的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>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>

4.0.0
aaa.bbb
服务组件
jbi服务程序集
0.0.1-快照
aaa.bbb
家长
1.0-快照
../pom.xml
aaa.bbb
服务单位
0.0.1-快照
org.apache.servicemix.tooling
jbi maven插件
3.2.3
真的
服务组合

我认为您误解了JBI组件/SharedLib/SA/SU或类加载器的一些概念,请查看了解更多详细信息

我不明白你所说的“共享库服务单元pom”是什么意思,因为在JBI规范中,SharedLib不应该有任何服务单元,它只是由JBI组件引用,就像servicemix camel一样,所有servicemix JBI组件只引用一个默认的SharedLib,名称是servicemix Shared

类org.apache.commons.dbcp.BasicDataSource来自commons-dbcp.jar,但commons-dbcp.jar不在smx3.x默认的sharedlib servicemix shared-${version}-installer.zip中,因此这意味着默认情况下,除非在su的xbean.xml中显式添加
您的共享库名
,否则所有servicemix camel su都无法看到此类