[JAVA-4437] GettingClusterSettings.getSrvHost() method not found error on application deployment while upgrading mongo java driver from 3.11.2 to 4.2.3 Created: 05/Jan/22 Updated: 27/Oct/23 Resolved: 06/Jan/22 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | VIjay Chauhan | Assignee: | Jeffrey Yemin |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | external-user | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Getting method not found error java.lang.NoSuchMethodError: com.mongodb.connection.ClusterSettings.getSrvHost() on application deployement after mongo java driver upgrade from mongo-java-driver 3.11.2 to mongodb-driver-core 4.2.3 mongodb-driver-sync 4.2.3 Spring boot version : 2.5.8 |
| Comments |
| Comment by Jeffrey Yemin [ 06/Jan/22 ] |
|
The exception you're getting is not an issue with the driver itself, so this is probably not the place to be asking this question anymore. Nevertheless, I referred your question to our colleagues on the Spring Data team. If they have any information, they will respond. |
| Comment by VIjay Chauhan [ 06/Jan/22 ] |
|
Hiii, I had mongo-java-driver 3.12.1 and spring-data-mongodb 2.2.5.RELEASE spring-boot-starter-parent 2.2.5.RELEASE previously Is there is any change or dependency we are missing or anything we are doing wrong please let us know the reason for such runtime error. mongodb-driver-sync-4.2.3 spring-data-mongodb 3.2.3 spring-boot-starter-parent 2.5.8 no compilation error with this but getting runtime error of class not found without using legacy |
| Comment by Jeffrey Yemin [ 06/Jan/22 ] |
|
If you're using the legacy com.mongodb.MongoClient instead of the more recently added com.mongodb.client.MongoClient, you'll need to also take a dependency on mongodb-driver-legacy. |
| Comment by VIjay Chauhan [ 06/Jan/22 ] |
|
Hi I found that old dependency of version 3.3.0 was used in project so after removal of that the issue is resolved now there is no old dependency is present only mongodb-driver-core 4.2.3 mongodb-driver-sync 4.2.3 and spring-data-mongodb-3.2.3 is present Now this error is observed: Spring boot version : 2.5.8 |
| Comment by Jeffrey Yemin [ 05/Jan/22 ] |
|
I suspect that what's happening is that when you moved from the uber jar (mongo-java-driver) to the non-uber jar (mongodb-driver-sync), you exposed a dependency on an earlier release (pre-3.10, where that method was added) of either mongodb-driver-core or mongo-java-driver. You'll need to check your dependencies/classpath to see where it's coming from. One way to do that is to enable verbose class loading (https://stackoverflow.com/questions/10230279/java-verbose-class-loading) to determine from which jar ClusterSettings is being loaded. Please let us know what you find. |
| Comment by VIjay Chauhan [ 05/Jan/22 ] |
|
On further debugging, looks like it is getting this error from DefaultClusterFactory.createCluster() method, else { return new DnsMultiServerCluster(clusterId, clusterSettings, serverFactory, dnsSrvRecordMonitorFactory); } |