Announcement Announcement Module
Collapse
No announcement yet.
Name of duplicate attribute use is 'repository-impl-postfix' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Name of duplicate attribute use is 'repository-impl-postfix'

    I am receiving a strange exception when trying to run a JUnit test to test my Spring configuration & Mongo.

    I receive:

    Caused by: org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 107 in XML document from class path resource [spring-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: ct-props-correct.4: Error for type 'mongo-repository'. Duplicate attribute uses with the same name and target namespace are specified. Name of duplicate attribute use is 'repository-impl-postfix'.

    spring-config.xml:
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mongo="http://www.springframework.org/schema/data/mongo"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                               http://www.springframework.org/schema/tx
                               http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                               http://www.springframework.org/schema/context
                               http://www.springframework.org/schema/context/spring-context-3.0.xsd
                               http://www.springframework.org/schema/data/mongo
                               http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
        <context:property-placeholder location="classpath:application.properties"/>

        <mongo:mongo id="mongo" host="${mongodb.host}" port="${mongodb.port}"/>
        <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
            <constructor-arg ref="mongo"/>
            <constructor-arg value="${mongodb.db.name}"/>
            <constructor-arg value="mycollection"/>
        </bean>
        <bean id="testString" class="java.lang.String">
            <constructor-arg value="Hello World"/>
        </bean>
    </beans>
    JUnit Test:

    PHP Code:
    package com.mdb.beltapp.core.test;

    import org.junit.Assert;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

    @
    RunWith(SpringJUnit4ClassRunner.class)
    @
    ContextConfiguration(locations = {"classpath:spring-config.xml"})
    public final class 
    TestMongo {

        @
    Autowired
        
    private String test;
        @
    Test
        
    public void testRepositories() {
            
    Assert.assertEquals("Hello World",test);
        }

        public 
    void setTest(String test) {
            
    this.test test;
        }

    Libraries are:
    aopalliance.jar
    spring-aop-3.0.5.jar
    spring-asm-3.0.5.jar
    spring-aspects-3.0.5.jar
    spring-beans-3.0.5.jar
    spring-context-3.0.5.jar
    spring-context.support-3.0.5.jar
    spring-core-3.0.5.jar
    spring-expression-3.0.5.jar
    spring-instrument-3.0.5.jar
    spring-instrument.tomcat-3.0.5.jar
    spring-jdbc-3.0.5.jar
    spring-jms-3.0.5.jar
    spring-orm-3.0.5.jar
    spring-oxm-3.0.5.jar
    spring-test-3.0.5.jar
    spring-transaction-3.0.5.jar
    spring-web-3.0.5.jar
    spring-web.servlet-3.0.5.jar
    spring-data-commons-aspects-1.0.0.M1.jar
    spring-data-commons-core-1.0.0.M1.jar
    spring-data-mongodb-1.0.0.M3.jar
    spring-data-mongodb-cross-store-1.0.0.M3.jar
    spring-data-mongodb-log4j-1.0.0.M3.jar


    Yes I do know I am doing nothing with Mongo or Spring Data directly yet in my test however I am relatively new to spring and have never known how to boot strap a JUnti test for Spring.

  • #2
    Problem resolved however it took much less time to guess at the solution (replace spring-data-commons-core-1.0.0.M1.jar with spring-data-commons-core-1.0.0.M3.jar) because the M3.jar is not
    easily found. There is no place to easily download the commons jars

    Comment

    Working...
    X