我已经安装了骆驼(版本 2.10.X),我可以使用 csv 和 xslt 处理器运行许多示例。现在我正在尝试使用 camel aggregator
。我改编了骆驼文档中的一个示例,这样当 3 个文件写入input
目录时,它们必须被聚合并发送到输出目录。
我的上下文如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" />
<bean id="aggregatorStrategy" class="org.apache.camel.processor.BodyInAggregatingStrategy" />
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:package>com.example.camel.wardemo</camel:package>
<camel:route>
<camel:from uri="file:/inputdir" />
<camel:aggregate strategyRef="aggregatorStrategy" completionSize="3">
<camel:correlationExpression>
<camel:simple>header.id</camel:simple>
</camel:correlationExpression>
<camel:to uri="file:/outdir" />
</camel:aggregate>
</camel:route>
</camel:camelContext>
但是在部署war文件时,应用程序没有启动并出现异常:(localhost_XXXXXX.log
5.06.2013 18:14:03 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
25.06.2013 18:14:05 org.apache.catalina.core.StandardContext listenerStart
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activemq' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel-1': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.camel.processor.BodyInAggregatingStrategy] for bean with name 'aggregatorStrategy' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.camel.processor.BodyInAggregatingStrategy
在我的上下文中,这应该是对这个标签的引用:
<bean id="aggregatorStrategy" class="org.apache.camel.processor.BodyInAggregatingStrategy" />
我究竟做错了什么?
谢谢!
编辑
这是我的pom.xml
<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>
<parent>
<groupId>com.example.camel</groupId>
<artifactId>CamelDemo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.example.camel</groupId>
<artifactId>CamelWarDemo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>CamelDemo :: WAR Demo</name>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-csv</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web</artifactId>
<scope>runtime</scope>
<type>war</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${camel-version}</version>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<systemProperties>
<systemProperty>
<name>com.sun.management.jmxremote</name>
<value />
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>