I am trying to learn MongoDB and in the same time write a simple REST application using Spring framework.

I have a simple model:

Code:
@Document
public class Permission extends documentBase{

@Indexed(unique = true)
private String name;

public   Permission(String name) {
    this.name = name;       
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}
}
Then I have a simple DAO:

Code:
@Repository
@Transactional 
@Profile({"production","repositoryTest","mongoIntegrationTest"})
public class DaoImpl   implements DAO  {

@Autowired
protected MongoTemplate mongoTemplate;

public <T> T addObject(T object) {      
    try {
      mongoTemplate.insert(object);       
    } catch ( DataAccessException e) {
        // TODO: handle exception
    }
    finally { return object;}
}
The I have my integration tests:

Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:mvc-dispatcher-servlet.xml", classpath:IntegrationContext.xml"},loader = TestXmlContextLoader.class)
@ActiveProfiles("mongoIntegrationTest")
public class RepositoryIntegrationTest extends AccountTestBase{

    @Autowired DAO repository;
    @Autowired WebApplicationContext wac;

    @Test
public void AddPermission() { 
    Permission permission_1 = new Permission("test");           
    Permission permission_2 = new Permission("test");           
    repository.addObject(permission_1);
    repository.addObject(permission_2);
}
}
My configuration:
Code:
<!-- MongoDB host -->
 <mongo:mongo host="${mongo.host.name}" port="${mongo.host.port}"/> 

 <!-- Template for performing MongoDB operations -->
 <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate" 
c:mongo-ref="mongo" c:databaseName="${mongo.db.name}"/>
I am expecting that, on adding "permission_2" their would be a exception thrown from MongoDB, which would be translated by Spring,, and catched as a DataAccessException in the DAO.

Looking at the log files from MongoDb I can see that a duplicated exception is thrown but it never reaches my DAO.

So,, I guess I am doing something wrong,,, but at the moment,, I am blind to my own misstakes.

If no one can see any obvious mistakes,,, then please,, how do I debug this?

//lg