You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MongoClientVersion does its best to determine mongodb driver version properly and use a proper driver API.
But looks like com.mongodb.internal.build.MongoDriverVersion.VERSION value is inlined and always 5.2.1 (for spring-data-mongodb 4.4.4), note LDC "5.2.1":
This will not work properly if one e.g. excludes driver 5.X version and provides 4.X explicitly instead, see stacktrace:
Stacktrace
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.springframework.data.mongodb.core.MongoTemplate.lambda$getCollectionNames$29(MongoTemplate.java:2353)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:582)
at org.springframework.data.mongodb.core.MongoTemplate.getCollectionNames(MongoTemplate.java:2351)
at smagellan.test.mongodb.SpringDataMongodbRunner.main(SpringDataMongodbRunner.java:15)
Caused by: java.lang.IllegalStateException: Unable to load com.mongodb.client.ListCollectionNamesIterable
at org.springframework.data.mongodb.util.MongoCompatibilityAdapter$MongoDatabaseAdapter.<clinit>(MongoCompatibilityAdapter.java:228)
... 4 more
Caused by: java.lang.ClassNotFoundException: com.mongodb.client.ListCollectionNamesIterable
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:534)
at java.base/java.lang.Class.forName(Class.java:513)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:299)
at org.springframework.data.mongodb.util.MongoCompatibilityAdapter$MongoDatabaseAdapter.<clinit>(MongoCompatibilityAdapter.java:225)
... 4 more
The text was updated successfully, but these errors were encountered:
smagellan
changed the title
MongoClientVersion might use a non-reliable way to fetch db driver version.
MongoClientVersion uses a non-reliable way to fetch db driver version.
Apr 8, 2025
Hello.
MongoClientVersion does its best to determine mongodb driver version properly and use a proper driver API.
But looks like com.mongodb.internal.build.MongoDriverVersion.VERSION value is inlined and always 5.2.1 (for spring-data-mongodb 4.4.4), note LDC "5.2.1":
Bytecode
Stacktrace
The text was updated successfully, but these errors were encountered: