ServiceMix (FuseESB) - 无法使用 AggregationStrategy 部署服务单元
我正在尝试将非常简单的 ESB 应用程序部署到 Apache ServiceMix (Fuse ESB),并且所有工作都正常,直到我尝试使用“AggregationStrategy”接口。我正在使用 EIP 和聚合器模式构建概念验证,但由于 NoClassDefFound 错误而无法部署我的工件。看起来像一个典型的类加载问题,但我不知道如何解决它。我尝试了两种方法:添加和删除对我的服务单元(servicemix-camel 类型)的camel-core 依赖项。
该应用程序的基础可以在此处找到。我已将路由定义修改为以下内容:
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-通用- 2011.02.1.fuse-02-11 |创建名称为“template”的 bean 时出错:bean 初始化失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“camel”的 bean:调用 init 方法失败; 嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建带有名称的bean “com.softwarepassion.tutorial.camel.MyRouteBuilder”:解析 bean 类上声明的构造函数 来自 ClassLoader 的 [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/] 父母=[[org.apache.xbean.classloader.JarFileClassLoader: 名称=SU 父类加载器 urls=[] 父母=[231.0, [camel-spring] 的 BundleDelegatingClassLoader (org.apache.camel.camel-spring)],BundleDelegatingClassLoader [camel-cxf (org.apache.camel.camel-cxf)],BundleDelegatingClassLoader 对于 [camel-cxf-transport (org.apache.camel.camel-cxf-transport)]]]]]] 失败的;嵌套异常是java.lang.NoClassDefFoundError: org/apache/camel/processor/aggregate/AggregationStrategy 07:50:49,627 |错误|使用-01-11/部署 |服务组件安装程序 | ?
? | 147 - org.apache.servicemix.jbi.deployer - 1.5.1.fuse-01-11 | 部署 SU 教程-camel-su 时出错
I'm trying to deploy very simple ESB application to Apache ServiceMix (Fuse ESB) and all works fine up to the point where I'm trying to use 'AggregationStrategy' interface. I'm building a proof of concept using EIP and aggregator pattern in particular and cannot deploy my artifact due to NoClassDefFound Error. Looks like a typical class loading issue but I'm out of ideas on how to resolve it. I have tried both: adding and removing camel-core dependency to my service unit (servicemix-camel type).
The basis of the application can be found here. I have modified my routes definition to the following:
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");
}
and my custom AggregationStrategy looks like this:
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;
}
}
I got the following error on plain ServiceMix as well as on FuseESB:
07:50:49,625 | ERROR | use-01-11/deploy | DefaultComponent
| ? ? | 151 - servicemix-common -
2011.02.1.fuse-02-11 | Error creating bean with name 'template': Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'camel': Invocation of init method failed;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'com.softwarepassion.tutorial.camel.MyRouteBuilder': Resolution of
declared constructors on bean Class
[com.softwarepassion.tutorial.camel.MyRouteBuilder] from 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-su/]
parents=[[org.apache.xbean.classloader.JarFileClassLoader: name=SU
parent class loader 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)]]]]]]
failed; nested exception is java.lang.NoClassDefFoundError:
org/apache/camel/processor/aggregate/AggregationStrategy 07:50:49,627
| ERROR | use-01-11/deploy | ServiceAssemblyInstaller | ?
? | 147 - org.apache.servicemix.jbi.deployer - 1.5.1.fuse-01-11 |
Error deploying SU tutorial-camel-su
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用 JBI,它是遗留的/已死的。
http://gnodet.blogspot.com/2010/12/thoughts-about -servicemix.html
使用 Camel 原型创建要部署在 ServiceMix 中的新 OSGi 项目。原型列表在这里
http://camel.apache.org/camel-maven-archetypes.html
例如camel-archetype-spring-dm或camel-archetype-blueprint
Do not use JBI its a legacy/dead.
http://gnodet.blogspot.com/2010/12/thoughts-about-servicemix.html
Use the Camel archetypes to create a new OSGi project to be deployed in ServiceMix. The list of archetypes is here
http://camel.apache.org/camel-maven-archetypes.html
For example the camel-archetype-spring-dm or camel-archetype-blueprint
对于任何寻找上述问题解决方案的人,我终于找到了 这里,我应该切换到 OSGI 类型的部署。您可以在 FuseESB 安装根目录的“examples”目录中找到工作的camel-osgi 示例项目。
For anyone looking for a solution to the above problem, I have finally found here, that I should switch to OSGI type of deployment. You can find working camel-osgi example project inside 'examples' directory at the root of your FuseESB installation.