2

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?

1
  • 1
    could you provide versions of server, driver you are using? Commented Nov 28, 2012 at 2:17

3 Answers 3

6

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.

Sign up to request clarification or add additional context in comments.

3 Comments

removing the multiple versions solved my problem.. thanks :)
Where does this need to run? I am facing the same issue, would really appreciate if someone could help me out. I am new to Scala.
I was running spark-shell --packages org.mongodb.spark:mongo-spark-connector_2.11:2.3.0 --jars mongo-hadoop-spark-2.0.2.jar,mongo-java-driver-3.2.2.jar earlier but running spark-shell --packages org.mongodb.spark:mongo-spark-connector_2.11:2.3.0 instead worked for me.
4

use this line.

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

Comments

4

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.