1

I'm trying to connect to mongoDB server from Java Servlet.
I added the following jars: bson-3.0.4.jar, mongodb-driver-3.0.4-javadoc.jar, mongodb-driver-core-3.0.4.jar and add this jars also to WEB-INF\lib directory.

And when i tried to run the following code:

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

I got the following exception:

java.lang.NoClassDefFoundError: com/mongodb/connection/BufferProvider

What i'm doing wrong?

2 Answers 2

6

Did you check out here, i think you need additional jar file.

http://mongodb.github.io/mongo-java-driver/3.0/driver/getting-started/installation-guide/#mongodb-driver

also checkout this link Having trouble connecting to MongoDB with Java

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

Comments

0

Couldn't it be better to use a dependency management like Maven or Gradle? I prefer to delegate someone else to resolve my dependencies...

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.