hello,
I read the article on POJO-producing
(http://camel.apache.org/pojo-producing.html) and thought this would be a
neat way of sending POJOs from my Spring MVC webapp to a Camel route. But I
can't seem to get Spring to inject the ProducerTemplate in my Spring MVC
Controller. The producer in the example below is null. Any suggestions would
be highly appreciated!

applicationContext.xml
<import resource="camel-context.xml"/>
<bean id="searchController" class="com.acme.controller.SearchController"/>

camel-context:
<context:annotation-config/>
<context:component-scan base-package="com.acme.routes" />
<camelContext xmlns="http://camel.apache.org/schema/spring";
id="routerCamelContext">
 <routeBuilder id="searchRouter" ref="searchRouter" />
</camelContext>

SearchRouter.java
from("direct:foo").log(LoggingLevel.INFO, "incoming :
${body}").to("direct:bar");

SearchController.java
@EndpointInject(uri = "direct:foo")
ProducerTemplate producer;
...
producer.sendBody(request);


The log says:
[main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.10.2
(CamelContext: routerCamelContext) is starting
[main] INFO org.apache.camel.spring.SpringCamelContext - Route: route1
started and consuming from: Endpoint[direct://foo]
[main] INFO org.apache.camel.spring.SpringCamelContext - Total 1 routes, of
which 1 is started.
[main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.10.2
(CamelContext: routerCamelContext) started in 0.319 seconds

but it all ends up in an NPE...



--
View this message in context: 
http://camel.465427.n5.nabble.com/Spring-doesn-t-inject-a-ProducerTemplate-tp5721657.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to