2013-06-25 101 views
0

我已經安裝了駱駝(版本2.10.X),我可以使用csv和xslt處理器運行很多示例。 現在我正在嘗試使用駱駝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> 

+0

燦你發佈pom.xml? –

+0

當然。往上看。 – Luixv

回答

1

的問題是,BodyInAggregatingStrategy不是因爲它的下/src/test/java駱駝核心依賴...

+0

感謝您的回答。那麼哪個依賴項缺失?或者應該在這裏做什麼? – Luixv

+0

不存在依賴關係,您只需創建自己的聚合策略類,因爲不包含此類聚合策略類(如果您想從頭開始,則從BodyInAggregatingStrategy複製) –