2

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?

Evyatar Elmaliah
  • 634
  • 1
  • 8
  • 23

2 Answers2

7

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

Community
  • 1
  • 1
Deendayal Garg
  • 5,030
  • 2
  • 19
  • 33
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...

Fernando Aspiazu
  • 953
  • 1
  • 10
  • 28