title: Spring-Data-Mongodb NoSuchMethodError when writing to db
body: <p>I'm building a spring webapp using mongodb but recently I began having problems with writing to DB. The following stack trace is what I get.</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [/afcrowther_blog]     threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.MongoPersistentProperty.isWritable()Z] with root cause
  java.lang.NoSuchMethodError:     org.springframework.data.mongodb.core.mapping.MongoPersistentProperty.isWritable()Z
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:415)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:412)
  at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:294)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:412)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:386)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:350)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:77)
  at org.springframework.data.mongodb.core.MongoTemplate.toDbObject(MongoTemplate.java:732)
  at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:714)
  at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:672)
  at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:663)
  </code></pre>
  
  <p>After reading up the most common cause of this seems to be dependency mismatches, but I'm not sure which dependencies are actually compatible with one another in that case.</p>
  
  <p>Pom.xml
          </p>
  
  <pre><code>    &lt;spring.version&gt;4.0.7.RELEASE&lt;/spring.version&gt;
      &lt;jackson.version&gt;1.9.2&lt;/jackson.version&gt;
      &lt;spring.security.version&gt;3.2.5.RELEASE&lt;/spring.security.version&gt;
  
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.11&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
          &lt;artifactId&gt;mongo-java-driver&lt;/artifactId&gt;
          &lt;version&gt;2.12.3&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;cglib&lt;/groupId&gt;
          &lt;artifactId&gt;cglib&lt;/artifactId&gt;
          &lt;version&gt;3.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-mongodb&lt;/artifactId&gt;
          &lt;version&gt;1.6.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-commons&lt;/artifactId&gt;
          &lt;version&gt;1.9.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-oxm&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.1.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;taglibs&lt;/groupId&gt;
          &lt;artifactId&gt;standard&lt;/artifactId&gt;
          &lt;version&gt;1.1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;${jackson.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;4.2.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-libs-snapshot&lt;/id&gt;
          &lt;name&gt;Spring Snapshot Repository&lt;/name&gt;
          &lt;url&gt;http://repo.spring.io/libs-snapshot&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;build&gt;
  
      &lt;finalName&gt;afcrowther blog&lt;/finalName&gt;
  
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.9&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;downloadSources&gt;true&lt;/downloadSources&gt;
                  &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  
  &lt;/build&gt;
  </code></pre>
  
  <p>These are mainly the latest release versions, although I changed spring framework to 4.0.7.Release to try and fix it, but I have also used 4.1.0.Release and the same exception occurs.</p>
  
  <p>Thanks</p>
  
  <p>EDIT: @Document Annotated class that throws the error, role set as a String until this problem is resolved</p>
  
  <pre><code>@Document(collection = "user")
  public class UserModel{
  
  @PersistenceConstructor
  public UserModel(String id, String firstName, String surname, String email,
          String password, String role) {
      this.id = id;
      this.firstName = firstName;
      this.surname = surname;
      this.email = email;
      this.password = password;
      this.role = role;
  }
  
  public UserModel(){
  
  }
  
  @Id
  private String id;
  
  @Field("firstName")
  @Indexed
  private String firstName;
  
  @Field("surname")
  private String surname;
  
  @Field("email")
  @Indexed(unique = true)
  private String email;
  
  @Field("password")
  private String password;
  
  @Field("role")
  private String role;
  
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  public String getFirstName() {
      return firstName;
  }
  
  public void setFirstName(String firstName) {
      this.firstName = firstName;
  }
  
  public String getSurname() {
      return surname;
  }
  
  public void setSurname(String surname) {
      this.surname = surname;
  }
  
  public String getEmail() {
      return email;
  }
  
  public void setEmail(String email) {
      this.email = email;
  }
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  public String getRole(){
      return role;
  }
  
  public void setRole(String role){
      this.role = role;
  }
  }
  </code></pre>