Question

I've installed camel (version 2.10.X) and I could run many examples using csv and xslt processors. Now I am trying to use the camel aggregator. I've adapted an example from the camel documentation so that when 3 files are written into the input directory they have to be aggregated and send to the output directory.

My context is as follows:

<?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>

but when deploying the war file the application doesn't start and troughs an exception: (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

This should be a reference to this tag in my context:

<bean id="aggregatorStrategy" class="org.apache.camel.processor.BodyInAggregatingStrategy" />

What am I doing wrong?

Thanks!

EDIT

This is my 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>

Was it helpful?

Solution

the issue is that the BodyInAggregatingStrategy isn't in the camel-core dependency because its under /src/test/java...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top