CompilerException java.lang.ClassNotFoundException: org.bson.types while trying to connect to mongo with Monger

9k Views Asked by At

Trying to connect to Mongo using Monger and I get the following error

CompilerException java.lang.ClassNotFoundException: org.bson.types

I have added the dependency [com.novemberain/monger "3.1.0"] in project.clj and did a lein re-install and is trying to import bson.types as :import [org.bson.types ObjectId].

The monger dependency is reflecting in my auto generated pom.xml file as

<dependency>
<groupId>com.novemberain</groupId>
<artifactId>monger</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>

Am I missing any dependency or what am I doing wrong ? .

2

There are 2 best solutions below

0
On BEST ANSWER

Looks like monger depends on org.mongodb:mongodb-driver, which does not include the bson parts of the mongo driver. So you'd also need to include the bson dep explicitly, which is org.mongodb:bson.

Looks like they also publish a org.mongodb:mongodb-java-driver uberjar that includes the driver, bson, and other stuff in a single dep. If you added that you'd get everything (but you should probably exclude those deps pulled in by monger to avoid conflicts).

0
On

Monger Jar file dependency need to be added at your jar location. This help me resolved the issue. Hope it helps you too.

Download the Monger Jar file from the below link

https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver/2.10.1