Reputation: 624
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?
Upvotes: 1
Views: 15218
Reputation: 993
Couldn't it be better to use a dependency management like Maven or Gradle? I prefer to delegate someone else to resolve my dependencies...
Upvotes: 0
Reputation: 5148
Did you check out here, i think you need additional jar file.
also checkout this link Having trouble connecting to MongoDB with Java
Upvotes: 6