Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
959 views
in Technique[技术] by (71.8m points)

java - Failed to create route route1

i have a trouble solving this exception and i don't know where i'm doing wrong. here's the Exception.

org.apache.camel.spring.boot.CamelSpringBootInitializationException: java.lang.RuntimeException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Filter[bean[ref:filter method:accept] -> []] <<< in route: Route(route1)[[From[file:D:/copyy/?noop=true]] -> [Filter[be... because of Definition has no children on Filter[bean[ref:filter method:accept] -> []]

Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Aggregate[true -> []] <<< in route: Route(route1)[[From[file:D:/xml/?noop=true]] -> [Aggregate[t... because of Definition has no children on Aggregate[true -> []]
Caused by: java.lang.IllegalArgumentException: Definition has no children on Aggregate[true -> []]

and here's my router :

<bean id="AggregatorDemo" class="com.javainuse.AggregatorDemo"/> 
<route>
    <from uri="file:D:/xml/?noop=true" />
        <aggregate strategyRef="AggregatorDemo">
        <correlationExpression>
        <constant>true</constant>
        </correlationExpression>
        </aggregate>
        <log message=".....${body}...."></log>
        <to uri="file:D:/Xmlcopy" />
</route>

and here's the aggregator class i'm using.

public class AggregatorDemo implements AggregationStrategy{

 public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

        if (oldExchange == null) {

            return newExchange;
        }

        String orders = oldExchange.getIn().getBody(String.class);
        String newLine = newExchange.getIn().getBody(String.class);


        orders = orders+ newLine;

        oldExchange.getIn().setBody(orders);


        return oldExchange;
 }

}

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Move these inside the <aggregate>

<log message=".....${body}...."></log>
<to uri="file:D:/Xmlcopy" />

So the aggregate has children, eg

 <aggregate strategyRef="AggregatorDemo">
   <correlationExpression>
     <constant>true</constant>
   </correlationExpression>
   <log message=".....${body}...."></log>
   <to uri="file:D:/Xmlcopy" />
 </aggregate>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...