1
votes

I just can't find the jar file that contains the class org.bson.types.ObjectId

First, I made sure I had the correct object and package name correct: http://api.mongodb.com/java/3.1/org/bson/types/ObjectId.html

...so, org.bson.types.ObjectId is the correct package+class name...

I downloaded a couple of versions [3.0.0, 3.1.0, 3.2.0, 3.2.2, 3.3.0] from here: https://oss.sonatype.org/content/repositories/releases/org/mongodb/mongodb-driver/

I explode them (unzip them) and I can see that the jars do contain a package org.bson.types but there is no ObjectId class in there (!!!).

IMPORTANT: The MondoDB page says that the BSON library is included in the mongo java driver so it should all be there I'd think; I should not have to download the bson library separately, right? See here: http://mongodb.github.io/mongo-java-driver/

I have a feeling I'll smack my forehead when someone tells me the answer (or maybe not).... Thanks for any hints!

2

2 Answers

1
votes

Arg, doh! I'll delete this question. This old project is using ANT and the MongoDB POM shows the dependencies I was missing. See: https://oss.sonatype.org/content/repositories/releases/org/mongodb/mongodb-driver/3.3.0/mongodb-driver-3.3.0.pom

<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>3.3.0</version>
<scope>compile</scope>
</dependency>

And those BSON missing classes are in the dependency here: https://oss.sonatype.org/content/repositories/releases/org/mongodb/bson/3.3.0/

Argg, this is why I should switch old projects from ANT to GRADLE when I revisit them. Or at least Maven... DOH!

0
votes

ObjectId class is available in the bson-3.0.1.jar , you can download the same at http://www.java2s.com/Code/Jar/b/Downloadbson301jar.htm