我正在尝试将非常简单的ESB应用程序部署到Apache ( ServiceMix,Fuse),所有这些都很好,直到我尝试使用'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 \x\x\x{e76f}\\x{e76f}\{e76f}\x{e76f}使用-01-11/deploy= DefaultComponent 创建名为“模板”的bean的org.springframework.beans.factory.BeanCreationException:错误:初始化失败;嵌套异常是创建名为“camel”的bean :调用init方法失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:错误创建bean,其名称为'com.softwarepassion.tutorial.camel.MyRouteBuilder':,解析了ClassLoader [[org.apache.xbean.classloader.JarFileClassLoader: name=org.apache.xbean.spring.context.FileSystemXmlApplicationContext@1c4d3b6 urls=file:/home/kris/apache-servicemix-4.4.1-fuse-01-11/data/jbi/tutorial-camel-sa/sus/tutorial-camel中已声明的bean类com.softwarepassion.tutorial.camel.MyRouteBuilder上的构造函数。-su/ parents=[[org.apache.xbean.classloader.JarFileClassLoader: name=SU父类加载器urls=[] parents=[231.0,骆驼-弹簧BundleDelegatingClassLoader (org.apache.camel.camel-spring),骆驼-cxf(org.apache.camel.camel-cxf) BundleDelegatingClassLoader (org.apache.camel.camel-cxf),骆驼-cxf-传输BundleDelegatingClassLoader (org.apache.camel.camel-cxf-运输)];嵌套的例外是java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError 07:50:49,627 \x\x\x{e76f}\{e76f}\ ?\x{e76f}147-1.5.1.FUSE-01-11 org.apache.servicemix.jbi.deployer部署SU教程-camel-su错误
发布于 2011-12-14 04:49:36
不要使用JBI,它是遗留的/死的。http://gnodet.blogspot.com/2010/12/thoughts-about-servicemix.html
使用Camel原型创建一个新的OSGi项目以部署在ServiceMix中。原型的列表在这里,http://camel.apache.org/camel-maven-archetypes.html
例如,骆驼原型-弹簧-dm或骆驼-原型-蓝图
发布于 2011-12-13 13:48:04
对于任何想要解决上述问题的人来说,我终于找到了这里,我应该切换到OSGI类型的部署。您可以在FuseESB安装的根目录的“示例”目录中找到运行中的camel示例项目。
https://stackoverflow.com/questions/8485498
复制相似问题