Unable to query data set from Mongo DB

I am getting the following exception while trying to fetch data from Mongo DB using a Java application.

String mongodbURL = env.getProperty("spring.data.mongodb.uri");
		 com.mongodb.client.MongoClient client = MongoClients.create( mongodbURL);

	        MongoDatabase mongoDatabase = client.getDatabase("EDD");
	        MongoCollection<org.bson.Document> coll = mongoDatabase.getCollection("ZipStoreDistanceData");
		MongoCollection<StoreListForZip> zipCodeMongoCollection = mongoDatabase.getCollection("ZipStoreDistanceData",
		Bson filter = and(eq("_id", zipcode), lte("storeList.distanceInMiles", distance));		
		StoreListForZip storeListForZip = zipCodeMongoCollection.find(filter).first();

The line StoreListForZip storeListForZip = zipCodeMongoCollection.find(filter).first();
is the one which throws exception.
The exception is below

Caused by: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.blah.blah.dto.StoreListForZip```

my document looks like below in Mongo DB


any insight into why the Java application is throwing this exception ?

my POJO class looks like below.

public class StoreListForZip {

	String id;

	String countryZip;

	@JsonProperty(value = "countryCode")
	String countryCode;

	@JsonProperty(value = "storeList")
	List<StoreDistance> storeList;



Hi :wave: @ivin_jacob,

This error message is indicating that there is a problem with the MongoDB codec configuration for a class called “StoreListForZip”. The exception is saying that it can’t find a codec (i.e. a class responsible for encoding and decoding instances of the class to and from BSON) for this class. To resolve this issue, you need to either define your own decoding logic or use a different class that already has a codec registered.

For Quick Reference check out this article: Java - Mapping POJOs | MongoDB

Link to MongoDB Java Driver: Quick Start - POJOs

I hope it helps!