2

Just started getting the following exception while starting the server:

Error creating bean with name 'myRepository': Invocation of init method failed;  nested exception is java.lang.NoClassDefFoundError: org/springframework/data/mapping/context/InvalidPersistentPropertyPath: org.springframework.data.mapping.context.InvalidPersistentPropertyPath

What changes could have caused this exception?

Thanks.

user1838830
  • 131
  • 1
  • 6
  • This doesn't seem related to SDN4. This bit here: `java.lang.NoClassDefFoundError` indicates that the real issue is that you're missing a dependency or JAR in your runtime environment. – FrobberOfBits Jul 14 '15 at 15:39
  • Which I think is likely due to some refactoring work on SDN4 / OGM in the snapshot build. For example http://stackoverflow.com/questions/31137728/sdn-4-inprocessserver-broken-in-snapshot-build – user1838830 Jul 14 '15 at 15:50
  • Can you update your m2 repo? mvn -U – Luanne Jul 14 '15 at 16:39
  • I'm actually experiencing the exact same issue, even after blowing away my Gradle cache. Is `InvalidPersistentPropertyPath` a part of the data commons library? – simonl Jul 14 '15 at 20:11
  • Found a workaround - see below – simonl Jul 14 '15 at 20:28

2 Answers2

5

I am using Gradle and was experiencing the exact same issue.

InvalidPersistentPropertyPath seems to have been introduced in the latest SNAPSHOT build of spring-data-commons (1.11.0.BUILD-SNAPSHOT). My project also includes Spring Data JPA which relies on a more stable version (1.11.0.M1). Gradle did some conflict resolution and went with the M1 library, which does not have the new class and resulted in the NoClassDefFoundError.

For now, I am working around this by telling Gradle to ignore spring-data-commons as a transitive dependency of JPA so that the SNAPSHOT build being pulled in as a transitive dependency of SDN is used:

compile("org.springframework.data:spring-data-jpa:$springDataJpaVersion") {
  exclude group: "org.springframework.data", module: "spring-data-commons"
}

If you're using Gradle, you can check for conflicts using:

./gradlew <project>:dependencies

I think it will be worthwhile to check on the release schedules for each of these projects but for not this workaround is allowing our builds to continue.

simonl
  • 1,240
  • 7
  • 19
  • Yes, changing to BUILD-SNAPSHOT is the right thing to do for now. We'll endeavour to ensure the correct version in subsequent builds. – ATG Jul 15 '15 at 10:00
  • Thanks simonl. I’m using Maven with Spring Boot 1.3.0.M1 so I’ve posted my version of the fix below. – user1838830 Jul 15 '15 at 19:10
0

I'm using Maven, with Spring Boot 1.3.0.M1, spring-data-neo4j 4.0.0.BUILD-SNAPSHOT and neo4j 2.2.2.

As simonl suggested overriding spring-data-commons 1.11.0.M1 with 1.11.0.BUILD-SNAPSHOT fixes the issue.

<!-- Fix ClassNotFoundException: org.springframework.data.mapping.PersistentPropertyAccessor -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
    <version>1.11.0.BUILD-SNAPSHOT</version>
</dependency>

I remember having to do this in the past when working with newer versions of Neo4j with SDN 3, but haven't needed the spring-data-commons override with SDN 4, until now.

user1838830
  • 131
  • 1
  • 6