[JAVA-2590] java.lang.NoSuchMethodError when initiating Created: 30/Aug/17  Updated: 27/Oct/23  Resolved: 30/Aug/17

Status: Closed
Project: Java Driver
Component/s: API, Builders
Affects Version/s: 3.5.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Rahadian Ahmad Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: crash
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, Java 1.8, Gradle



 Description   

I'm trying to initialize the client with this code:

MongoClientURI clientURI = new MongoClientURI("mongodb://spammer:123mongo456@67.205.151.97/spammer");
_globalClient = new MongoClient(clientURI);

but i got this exception:
java.lang.NoSuchMethodError: com.mongodb.connection.SslSettings$Builder.context(Ljavax/net/ssl/SSLContext;)Lcom/mongodb/connection/SslSettings$Builder;
at com.mongodb.MongoClientOptions.<init>(MongoClientOptions.java:180)
at com.mongodb.MongoClientOptions.<init>(MongoClientOptions.java:54)
at com.mongodb.MongoClientOptions$Builder.build(MongoClientOptions.java:1474)
at com.mongodb.MongoClientURI.getOptions(MongoClientURI.java:336)
at com.mongodb.Mongo.createCluster(Mongo.java:701)
at com.mongodb.Mongo.<init>(Mongo.java:307)
at com.mongodb.Mongo.<init>(Mongo.java:303)
at com.mongodb.MongoClient.<init>(MongoClient.java:291)

i installed the lib with gradle :
compile 'org.mongodb:mongodb-driver:3.5.0'



 Comments   
Comment by Jeffrey Yemin [ 30/Aug/17 ]

The com.mongodb.connection.SslSettings.Builder#context method was introduced in the 3.5 release, so I suspect what's happening is that somewhere in your gradle configuration an older version of mongodb-driver-core is being pulled in.

Try executing the dependencies gradle task to see the dependency tree for your project. It should help to determine where an older version of mongodb-driver-core is being pulled in.

Generated at Thu Feb 08 08:57:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.