简体   繁体   中英

Camel normalizer bean not registered

I'm trying to implement a normalizer the way it's written here: http://camel.apache.org/normalizer.html

I'm getting this exception:

org.apache.camel.NoSuchBeanException: No bean could be found in the registry for
: normalizer

My .configure() in the RouteBuilder looks like this:

public void configure() throws Exception {

    JndiContext context = new JndiContext();
    context.bind("normalizer", new MyNormalizer());

    CamelContext camelContext = new DefaultCamelContext(context);
    camelContext.addRoutes(this);

    from("activemq:queue:input.splitter")
            .split().tokenizeXML("person").streaming()
            .to("activemq:queue:output.splitter");

    from("activemq:queue:input.normalizer")
            .choice()
            .when().xpath("//persons/person/position").to("bean:normalizer?method=positionChange")
            .end()
            .to("activemq:queue:output.normalizer");

}

The normalizer looks like this:

public class MyNormalizer {
    public void positionChange(Exchange exchange, @XPath("//persons/person/position") String name) {
        exchange.getOut().setBody(createPerson(name));
    }

    private String createPerson(String name) {
        return name;
    }
}

I found one solution about adding that piece of code into the RouteBuilder:

JndiContext context = new JndiContext();
context.bind("normalizer", new MyNormalizer());

CamelContext camelContext = new DefaultCamelContext(context);

But it didn't give any result. So what could be the problem here?

The solution was found. The bean has to be specified in the conf/camel.xml. In my case the definition looks like this:

<bean name="normalizer" id="normalizer" class="com.myroute.route.normalizer.MyNormalizer"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM