1

If you create a new Spring Boot project on start.spring.io with the Web and MongoDB module, add any @Document annotated class, and in addition upgrade the kotlin.version from 1.2.10 to 1.2.21 you get a NoClassDefFoundError:

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M7:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 1; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mappingMongoConverter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/jvm/internal/impl/load/kotlin/reflect/ReflectKotlinClass:
kotlin.reflect.jvm.internal.impl.load.kotlin.reflect.ReflectKotlinClass

When the @Document annotated class is removed the application starts with no issues.

From the error message it looks like the MongoDataAutoConfiguration requires the ReflectKotlinClass, which is not found in the classpath. The kotlin-reflect module is in the dependency list. Is there any other kotlin module required?

Gregor
  • 2,917
  • 5
  • 28
  • 50

1 Answers1

1

It looks like there was a bug report filed, adressing the same issue: https://jira.spring.io/browse/DATACMNS-1245 With spring-data-commons 2.0.3.RELEASE the problem does not longer occur.

Gregor
  • 2,917
  • 5
  • 28
  • 50