[JAVA-4438] Mongo java driver upgrade from 3.12.1 to 4.2.3 throws method not found errors Created: 06/Jan/22 Updated: 27/Oct/23 Resolved: 08/Feb/22 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | Sanket Chauhan | Assignee: | Jeffrey Yemin |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | external-user | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Documentation Changes: | Not Needed |
| Description |
|
Hii We had to update spring boot to 2.5.8 hence we made few changes to update dependencies as follow As we were using newly added import com.mongodb.client.MongoClient; *We resolved all compilation error but on deployment we got errors like methos not found for *getSrvHost() on further debugging we found that old dependency mongo-java-driver 3.3.0 was already present in project We excluded that and above issue is resolved now no old dependency is present but still we are getting following error without using legacy API approach java.lang.NoClassDefFoundError: com/mongodb/MongoClient We are completely stuck at this point |
| Comments |
| Comment by PM Bot [ 08/Feb/22 ] |
|
There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please feel free to comment on this if you're able to provide more information. |
| Comment by Jeffrey Yemin [ 10/Jan/22 ] |
|
sanket@yopmail.com no on will be able to move this issue forward without more information about your application, or at least a full stack trace. The only thing we can tell you right now is that your application has ended up with a mix of dependencies between the 3.x and 4.x drivers, and you need to figure out where the 3.x dependencies are coming from and then remove them. Without a stack trace, the next best option would be for you to post a full Java project (i.e with Maven pom.xml or equivalent) that demonstrates the problem.
|
| Comment by Sanket Chauhan [ 10/Jan/22 ] |
|
There is no stack trace for the same getting single line error only but with further debugging we found that there are few cron job running through our code which are asynchronous. Mongo java driver 3.12.1 was async driver and we are shifted to mongodb-driver-sync 4.2.3 shifting from async to sync can create such issues? Is there is any full fleshed document for mongo driver and spring data mongodb upgrade ? |
| Comment by Mark Paluch [ 07/Jan/22 ] |
|
For the record, Spring Boot 2.5.8 is compatible with Spring Data MongoDB 3.2.x and pulls in the driver version 4.2.3. |
| Comment by Jeffrey Yemin [ 06/Jan/22 ] |
|
Please paste in the full stack trace for the NoSuchMethodError. That method was indeed removed in the 4.0 release, so you would need to figure out what is attempting to call it. |
| Comment by Sanket Chauhan [ 06/Jan/22 ] |
|
On addition of mongodb-driver-legacy 4.2.3 dependency it throws different error java.lang.NoSuchMethodError: com.mongodb.MongoClient.setWriteConcern(Lcom/mongodb/WriteConcern;)V |
| Comment by Jeffrey Yemin [ 06/Jan/22 ] |
|
Looks like one of your colleagues already reported this in If you do need further help from MongoDB:
|