Upgrading to Mongo 4.4 - Getting "Can't find a codec for class java.util.LinkedHashMap" for persisting Nested objectsr

We are migrating to Mongo Driver 4.4 from 3.x.x and we are getting this error

Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.util.LinkedHashMap.
	at org.bson.internal.CodecCache.lambda$getOrThrow$1(CodecCache.java:52)
	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
	at org.bson.internal.CodecCache.getOrThrow(CodecCache.java:51)
	at org.bson.internal.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:64)
	at org.bson.internal.ChildCodecRegistry.get(ChildCodecRegistry.java:52)
	at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:206)
	at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:165)
	at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:44)

This happens whenever we are trying to insert a nested object and for some strange reason Mongo Driver refer the nested object as a LinkedHashMap and then try to encode it and fails .

Does anyone have any ideas about this error ?

Just found that we need to use the MapCodec as DocumentCodec now uses MapCodec explicitly in version 4.xx