Hi

What version of Camel do you use?

And there must be a CamelContext defined; This is the Camel runtime,
and you always need that.


On Thu, Oct 25, 2012 at 10:46 PM, garrydias <garryd...@gmail.com> wrote:
> Hi guys
>
> Why producerTemplate is not created if there´s no camelContext declared in
> my application.
>
> I put the <camel:template id="producerTemplate"  /> element in my spring
> context xml but it can not be injected if this xml file doesn´t contains a
> camelContext declared with at least one route.
>
> I don´t need routes, don´t need camelContext, but I need to send a message
> to an activemq endpoint.
>
> If I try autowire the producerTemplate
>
>     @Autowired
>     private ProducerTemplate template;
>
> this error accurs:
> ...
> /Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'producerTemplate': FactoryBean threw exception on
> object creation; nested exception is java.lang.NullPointerException
>         at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
>         at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
>         at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
>         at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
>         at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
>         at
> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
>         ... 23 more
> Caused by: java.lang.NullPointerException
>         at org.apache.camel.impl.ProducerCache.<init>(ProducerCache.java:64)
>         at org.apache.camel.impl.ProducerCache.<init>(ProducerCache.java:60)
>         at
> org.apache.camel.impl.DefaultProducerTemplate.doStart(DefaultProducerTemplate.java:706)
>         at 
> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
>         at 
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)/
>
> ...
>
>
> If I try:
>
>     @Produce(uri="activemq:foo")
>     private ProducerTemplate template;
>
> the /template/ attribute is null.
>
> Who can tell my why it happens. I could not find anything in the reference
> http://camel.apache.org/producertemplate.html.
>
> Thanx
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/ProducerTemplate-cannot-be-autowired-if-no-CamelContext-are-available-tp5721571.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to