It looks like you don’t have any camel context definition inside of spring 
configuration file.
It could cause some trouble as the endpoint need to have the reference of the 
camel context.


--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On July 11, 2014 at 6:14:35 PM, simafengyun (273132...@qq.com) wrote:
> Hi Willem,
>  
> My code like that(not the real code)
>  
> *in xml: *
>  
> > uri="seda:trades?size=1000000&concurrentConsumers=20&waitForTaskToComplete=Never"
> >   
> xmlns="http://camel.apache.org/schema/spring"/>
>  
> > xmlns="http://camel.apache.org/schema/spring";>
>  
>  
>  
>  
>  
>  
>  
> *in java: *
>  
> //load spring xml
> final AbstractXmlApplicationContext springAppContext= new
> ClassPathXmlApplicationContext("testSpring.xml");
>  
>  
> //registry spring xml to camel context
> ActorSystem system = ActorSystem.create("some-system");
> Camel camel = CamelExtension.get(system);
> camel.context().setRegistry(new
> ApplicationContextRegistry(springAppContext));
> springAppContext.refresh();
>  
>  
> // add the routesContext to camelContext
> ArrayList rdList =
> (ArrayList)camel.context().getRegistry().lookup("defaultRoutes");  
> RouteDefinition rd = rdList.get(0);
> CamelExtension.get(system).context().addRouteDefinition(rd);
>  
> *Error:*
>  
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'testSeda': 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:1440)
>   
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:247)
>   
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
>   
> at
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
>   
> at
> org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:66)
>   
> at
> org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:49)
>   
> ... 21 more
> Caused by: java.lang.NullPointerException
> at
> org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:46)
>   
> at
> org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:30)
>   
> at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
>   
> ... 28 more
>  
>  
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/How-to-use-a-public-endpoint-outside-of-camecontext-tp5752336p5753714.html
>   
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  

Reply via email to