Announcement Announcement Module
Collapse
No announcement yet.
No bean named 'mongoDbFactory' is defined - 1.0.0.build-snapshot Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No bean named 'mongoDbFactory' is defined - 1.0.0.build-snapshot

    Hello,
    I'm trying to set up my application using the following spring data version :
    Code:
     		<dependency>
    		 <groupId>org.springframework.data</groupId>
    		 <artifactId>spring-data-mongodb</artifactId>
    		 <version>1.0.0.BUILD-SNAPSHOT</version>
    		</dependency>
    My appliation starts correctly with 1.0.0.M2, but using the snapshot, I get the following error :

    Code:
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mongoDbFactory' is defined
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    Here is my mongo-config.xml:
    Code:
    	<mongo:mongo host="localhost" port="27017" />
    	<mongo:mapping-converter base-package="org.avricot.avriopinion.document"/> 
    
    	<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
    		    <constructor-arg name="mongo" ref="mongo" />
    		    <constructor-arg name="databaseName" value="pitwitt" />
    		    <constructor-arg name="defaultCollectionName" value="opinion" />
    		    <constructor-arg name="mongoConverter" ref="mappingConverter"/>
    	</bean>
    
    	<mongo:repositories base-package="org.avricot.avriopinion.repository"
    		mongo-template-ref="mongoTemplate" />
    Am I forgetting something ?
    I can't see anything about mongoDbFactory configuration in the documentation.
    Not sure to understand why should I need a mongoDbFactory ?

    adding the following doesn't work neither :
    (fail with the following error :org.springframework.beans.factory.UnsatisfiedDepe ndencyException: Error creating bean with name 'mongoTemplate' defined in ServletContext resource [/WEB-INF/mongo-config.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.data.document.mongodb.MongoDbF actory]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?)
    Code:
    	<bean id="mongoDbFactory" class="org.springframework.data.document.mongodb.MongoDbFactoryBean">
    		 <constructor-arg name="mongo" ref="mongo" />
    	     <constructor-arg name="databaseName" value="pitwitt" />
    	</bean>
    Thanks for your help
    Last edited by Quentin; May 24th, 2011, 01:59 PM.

  • #2
    I've had the same issue:

    try this:

    Code:
            <mongo:mongo host="localhost"/>
    
    	<mongo:db-factory dbname="myDBName" />
    
    	<mongo:mapping-converter base-package="com.x.y.core.beans" id="converter"/> 
    	
    	<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
    		<constructor-arg ref="mongoDbFactory" />
    		<constructor-arg name="mongoConverter" ref="converter"/>
    		<property name="writeResultChecking" value="EXCEPTION"/>
    	</bean>
    note the new setting mongo:db-factory, and the template constructor have changed as well.

    Comment


    • #3
      yipee !
      Thanks, it's working.
      But do you know where is the xsd for the snapshot ?

      Comment


      • #4
        org.springframework.data.document.mongodb.config package in spring-data-mongodb.jar

        Comment


        • #5
          Im using this:

          https://github.com/SpringSource/spri...-mongo-1.0.xsd

          Comment


          • #6
            great !
            thank you

            Comment

            Working...
            X