You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by lokeshru <lo...@yahoo.com> on 2013/02/21 13:48:29 UTC

Unable to connect to mongodb using camel

In my camel RouteConfig.java I am not able to connect to mongo database. I
get the following exception : Caused by:
org.apache.camel.NoSuchBeanException: No bean could be found in the registry
for: myDb of type: com.mongodb.Mongo at
org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:130)
at
org.apache.camel.component.mongodb.MongoDbComponent.createEndpoint(MongoDbComponent.java:43)
at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:91)
at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:461)
... 42 more

RouteConfig.java from("jms:queue:Test").bean(new
SomeBean()).to("mongodb:mydb=flights&collection=tickets&operation=insert");

camel-context.xml 

	<bean id="mongoTemplate"
class="org.springframework.data.mongodb.core.MongoTemplate">
		<constructor-arg ref="mongoDbFactory"/> 	
	</bean>
	<bean id ="mongoDbFactory"
class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
		<constructor-arg ref="mongo"/>
		<constructor-arg name="databaseName" value="db" type="String"/>
	</bean>
	<bean id="myDb" class="com.mongodb.Mongo">
		<constructor-arg name="host" value="127.0.0.1" type="String"/>
		<constructor-arg name="port" value="27017" type="int"/>
	</bean>

Any help is appreciated

thanks Lokesh




--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-connect-to-mongodb-using-camel-tp5727950.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Unable to connect to mongodb using camel

Posted by lokeshru <lo...@yahoo.com>.
Hi Willem,
   It was my mistake, I realized that my camel-context.xml is not getting
loaded.  So whatever definitions I give in that it doesnt take, where shall
I define myDb. 

  I followed camel's camel-example-spring-javaconfig example.

thanks
Lokesh





--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-connect-to-mongodb-using-camel-tp5727950p5727958.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Unable to connect to mongodb using camel

Posted by Willem jiang <wi...@gmail.com>.
Hi,

How did you create the CamelContext?
I didn't find the camelContext related definition in the camel-context.xml.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, February 21, 2013 at 8:48 PM, lokeshru wrote:

> In my camel RouteConfig.java I am not able to connect to mongo database. I
> get the following exception : Caused by:
> org.apache.camel.NoSuchBeanException: No bean could be found in the registry
> for: myDb of type: com.mongodb.Mongo at
> org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:130)
> at
> org.apache.camel.component.mongodb.MongoDbComponent.createEndpoint(MongoDbComponent.java:43)
> at
> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:91)
> at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:461)
> ... 42 more
>  
> RouteConfig.java from("jms:queue:Test").bean(new
> SomeBean()).to("mongodb:mydb=flights&collection=tickets&operation=insert");
>  
> camel-context.xml  
>  
> <bean id="mongoTemplate"
> class="org.springframework.data.mongodb.core.MongoTemplate">
> <constructor-arg ref="mongoDbFactory"/>  
> </bean>
> <bean id ="mongoDbFactory"
> class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
> <constructor-arg ref="mongo"/>
> <constructor-arg name="databaseName" value="db" type="String"/>
> </bean>
> <bean id="myDb" class="com.mongodb.Mongo">
> <constructor-arg name="host" value="127.0.0.1" type="String"/>
> <constructor-arg name="port" value="27017" type="int"/>
> </bean>
>  
> Any help is appreciated
>  
> thanks Lokesh
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-connect-to-mongodb-using-camel-tp5727950.html
> Sent from the Camel Development mailing list archive at Nabble.com (http://Nabble.com).