After migration to SB 3.5.0
I can see in my project (snippet from Gradle's dep
task):
| \--- org.springframework.boot:spring-boot-starter-data-mongodb -> 3.5.0
| +--- org.springframework.boot:spring-boot-starter:3.5.0 (*)
| +--- org.mongodb:mongodb-driver-sync:5.4.0
| | +--- org.mongodb:bson:5.4.0 -> 5.5.0
| | \--- org.mongodb:mongodb-driver-core:5.4.0 -> 5.5.0
| | \--- org.mongodb:bson:5.5.0
| \--- org.springframework.data:spring-data-mongodb:4.5.0
| +--- org.mongodb:mongodb-driver-core:5.5.0 (*)
You can see two version of mongodb-driver-core
: 5.4.0
and 5.5.0
that are both brought by spring-boot-starter-data-mongodb
, one directly and the other one transitively (via org.springframework.data:spring-data-mongodb
). The snippet from the application log (from running test) is as below:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.mongodb.client.internal.MongoClientImpl.getStreamFactory(MongoClientImpl.java:304)
The following method did not exist:
'com.mongodb.internal.connection.StreamFactory com.mongodb.internal.connection.StreamFactoryHelper.getSyncStreamFactory(com.mongodb.MongoClientSettings, com.mongodb.spi.dns.InetAddressResolver, com.mongodb.connection.SocketSettings)'
The calling method's class, com.mongodb.client.internal.MongoClientImpl, was loaded from the following location:
jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/org.mongodb/mongodb-driver-sync/5.4.0/d653f1994afa21bc930ea509b92f75c2bfd6e5f/mongodb-driver-sync-5.4.0.jar!/com/mongodb/client/internal/MongoClientImpl.class
The called method's class, com.mongodb.internal.connection.StreamFactoryHelper, is available from the following locations:
jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/org.mongodb/mongodb-driver-core/5.5.0/e90f2a877a7538053a7579e65fd6f610f16c1658/mongodb-driver-core-5.5.0.jar!/com/mongodb/internal/connection/StreamFactoryHelper.class
The called method's class hierarchy was loaded from the following locations:
com.mongodb.internal.connection.StreamFactoryHelper: file:/Users/user/.gradle/caches/modules-2/files-2.1/org.mongodb/mongodb-driver-core/5.5.0/e90f2a877a7538053a7579e65fd6f610f16c1658/mongodb-driver-core-5.5.0.jar
Comment From: philwebb
Thanks for reporting the issue. It looks like an upgrade happened in Spring Data a couple of weeks ago and we had already moved to track only patch releases at that point.
I think we should consider breaking our own rules and upgrading to 5.5.0 in Spring Boot 3.5.1. Flagging to see what the team thing.
Comment From: wilkinsona
Yeah, I think we should upgrade. However, that doesn't explain the mismatched versions.
@vanta, if you're using Spring Boot's dependency management, you should see 5.4.0 for all Mongo driver dependencies. For example, here's the compile classpath of a freshly generated project from start.spring.io:
compileClasspath - Compile classpath for source set 'main'.
\--- org.springframework.boot:spring-boot-starter-data-mongodb -> 3.5.0
+--- org.springframework.boot:spring-boot-starter:3.5.0
| +--- org.springframework.boot:spring-boot:3.5.0
| | +--- org.springframework:spring-core:6.2.7
| | | \--- org.springframework:spring-jcl:6.2.7
| | \--- org.springframework:spring-context:6.2.7
| | +--- org.springframework:spring-aop:6.2.7
| | | +--- org.springframework:spring-beans:6.2.7
| | | | \--- org.springframework:spring-core:6.2.7 (*)
| | | \--- org.springframework:spring-core:6.2.7 (*)
| | +--- org.springframework:spring-beans:6.2.7 (*)
| | +--- org.springframework:spring-core:6.2.7 (*)
| | +--- org.springframework:spring-expression:6.2.7
| | | \--- org.springframework:spring-core:6.2.7 (*)
| | \--- io.micrometer:micrometer-observation:1.14.7 -> 1.15.0
| | \--- io.micrometer:micrometer-commons:1.15.0
| +--- org.springframework.boot:spring-boot-autoconfigure:3.5.0
| | \--- org.springframework.boot:spring-boot:3.5.0 (*)
| +--- org.springframework.boot:spring-boot-starter-logging:3.5.0
| | +--- ch.qos.logback:logback-classic:1.5.18
| | | +--- ch.qos.logback:logback-core:1.5.18
| | | \--- org.slf4j:slf4j-api:2.0.17
| | +--- org.apache.logging.log4j:log4j-to-slf4j:2.24.3
| | | +--- org.apache.logging.log4j:log4j-api:2.24.3
| | | \--- org.slf4j:slf4j-api:2.0.16 -> 2.0.17
| | \--- org.slf4j:jul-to-slf4j:2.0.17
| | \--- org.slf4j:slf4j-api:2.0.17
| +--- jakarta.annotation:jakarta.annotation-api:2.1.1
| +--- org.springframework:spring-core:6.2.7 (*)
| \--- org.yaml:snakeyaml:2.4
+--- org.mongodb:mongodb-driver-sync:5.4.0
| +--- org.mongodb:bson:5.4.0
| \--- org.mongodb:mongodb-driver-core:5.4.0
| \--- org.mongodb:bson:5.4.0
\--- org.springframework.data:spring-data-mongodb:4.5.0
+--- org.mongodb:mongodb-driver-core:5.5.0 -> 5.4.0 (*)
+--- org.springframework:spring-tx:6.2.7
| +--- org.springframework:spring-beans:6.2.7 (*)
| \--- org.springframework:spring-core:6.2.7 (*)
+--- org.springframework:spring-context:6.2.7 (*)
+--- org.springframework:spring-beans:6.2.7 (*)
+--- org.springframework:spring-core:6.2.7 (*)
+--- org.springframework:spring-expression:6.2.7 (*)
+--- org.springframework.data:spring-data-commons:3.5.0
| +--- org.springframework:spring-core:6.2.7 (*)
| +--- org.springframework:spring-beans:6.2.7 (*)
| \--- org.slf4j:slf4j-api:2.0.2 -> 2.0.17
\--- org.slf4j:slf4j-api:2.0.2 -> 2.0.17
Comment From: GreyTeardrop
We faced the same issue for MongoDB driver dependencies in 3.5.0. It does not happen if io.spring.dependency-management
is used - all versions of org.mongodb:
dependencies are forced to 5.4.0 in that case. It can be reproduced if Gradle platform
is used instead.
The simplest reproducer uses a new start.spring.io project with a patch:
Index: build.gradle.kts
===================================================================
diff --git a/build.gradle.kts b/build.gradle.kts
--- a/build.gradle.kts (revision 33988281e86a77db15d31b6bd74df8601bb08531)
+++ b/build.gradle.kts (date 1748036943498)
@@ -2,7 +2,6 @@
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
id("org.springframework.boot") version "3.5.0"
- id("io.spring.dependency-management") version "1.1.7"
}
group = "com.github.greyteardrop"
@@ -19,6 +18,7 @@
}
dependencies {
+ implementation(platform("org.springframework.boot:spring-boot-dependencies:3.5.0"))
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation("org.springframework.boot:spring-boot-starter-test")