我正在尝试将非常简单的 ESB 应用程序部署到 Apache ServiceMix (Fuse ESB) 并且在我尝试使用“AggregationStrategy”接口之前一切正常。我正在使用 EIP 和聚合器模式构建概念证明,并且由于 NoClassDefFound 错误而无法部署我的工件。看起来像一个典型的类加载问题,但我不知道如何解决它。我已经尝试了这两种方法:向我的服务单元添加和删除骆驼核心依赖项(servicemix-camel 类型)。
可以在此处找到应用程序的基础。我已将路线定义修改为以下内容:
public void configure() {
from("activemq:test2").split(xpath("/notes/note")).parallelProcessing().process(new NoteProcessor()).to("activemq:test3");
from("activemq:test3").aggregate(header("id"), new MyAggregationStrategy()).completionTimeout(3000).to("activemq:test");
}
我的自定义 AggregationStrategy 如下所示:
package com.softwarepassion.tutorial.camel;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.processor.aggregate.AggregationStrategy;
public class MyAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
Message newIn = newExchange.getIn();
String oldBody = oldExchange.getIn().getBody(String.class);
String newBody = newIn.getBody(String.class);
newIn.setBody(oldBody + newBody);
return newExchange;
}
}
我在普通 ServiceMix 和 FuseESB 上收到以下错误:
07:50:49,625 | 错误 | 使用-01-11/部署 | 默认组件
| ? ? | 151 - servicemix-common - 2011.02.1.fuse-02-11 | 创建名为“模板”的 bean 时出错:bean 初始化失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“camel”的 bean 时出错:调用 init 方法失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为 'com.softwarepassion.tutorial.camel.MyRouteBuilder' 的 bean 时出错:从 ClassLoader 解析 bean 类 [com.softwarepassion.tutorial.camel.MyRouteBuilder] 上声明的构造函数[[org.apache.xbean.classloader.JarFileClassLoader:名称=org.apache.xbean.spring.context.FileSystemXmlApplicationContext@1c4d3b6 urls=[文件:/home/kris/apache-servicemix-4.4。1-fuse-01-11/data/jbi/tutorial-camel-sa/sus/tutorial-camel-su/] parents=[[org.apache.xbean.classloader.JarFileClassLoader: name=SU父类加载器urls=[ ] parents=[231.0, BundleDelegatingClassLoader for [camel-spring (org.apache.camel.camel-spring)], BundleDelegatingClassLoader for [camel-cxf (org.apache.camel.camel-cxf)], BundleDelegatingClassLoader for [camel-cxf -transport (org.apache.camel.camel-cxf-transport)]]]]]] 失败;嵌套异常是 java.lang.NoClassDefFoundError: org/apache/camel/processor/aggregate/AggregationStrategy 07:50:49,627 | 错误 | 使用-01-11/部署 | ServiceAssemblyInstaller | ? [camel-cxf (org.apache.camel.camel-cxf)] 的 BundleDelegatingClassLoader,[camel-cxf-transport (org.apache.camel.camel-cxf-transport)]]]]]] 的 BundleDelegatingClassLoader 失败;嵌套异常是 java.lang.NoClassDefFoundError: org/apache/camel/processor/aggregate/AggregationStrategy 07:50:49,627 | 错误 | 使用-01-11/部署 | ServiceAssemblyInstaller | ? [camel-cxf (org.apache.camel.camel-cxf)] 的 BundleDelegatingClassLoader,[camel-cxf-transport (org.apache.camel.camel-cxf-transport)]]]]]] 的 BundleDelegatingClassLoader 失败;嵌套异常是 java.lang.NoClassDefFoundError: org/apache/camel/processor/aggregate/AggregationStrategy 07:50:49,627 | 错误 | 使用-01-11/部署 | ServiceAssemblyInstaller | ?
? | 147 - org.apache.servicemix.jbi.deployer - 1.5.1.fuse-01-11 | 部署 SU tutorial-camel-su 时出错