James Raitsev
James Raitsev

Reputation: 96391

MongoDB, java.lang.NoSuchFieldError

Program is failing on line 1

    MongoClient mongoClient = new MongoClient("localhost", 27017);

With

java.lang.NoSuchFieldError: ACKNOWLEDGED
    at com.mongodb.MongoClientOptions$Builder.<init>(MongoClientOptions.java:54)
    at com.mongodb.MongoClient.<init>(MongoClient.java:126)
    at com.mongodb.MongoClient.<init>(MongoClient.java:115)

While mongo is,

Tue Nov 27 15:40:13 [initandlisten] waiting for connections on port 27017

What am i doing wrong please?

Upvotes: 2

Views: 8770

Answers (3)

Enayat
Enayat

Reputation: 4042

I had the same problem and I realized that I have two java libraries for reading Mongo DB. When I removed one of them (com.mongodb-x-x.jar), the error disappeared.

Upvotes: 4

jyemin
jyemin

Reputation: 3813

I suspect that you have multiple versions of the mongo-java-driver jar in your classpath. Try running with -verbose:class to see where the WriteConcern class is being loaded from.

Upvotes: 6

Prem Kumar K
Prem Kumar K

Reputation: 59

use this line.

Mongo mongo= new Mongo("localhost", 27017);

Upvotes: 4

Related Questions