Chapter1 - Projection test Errors as "org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class [Ljava.lang.String;."

While running the Projection test it errors with the reason “org.bson.codecs.configuration.CodecConfigurationException: Can’t find a codec for class [Ljava.lang.String;.”

Can any one help me on this.

Found the issue. It is due to the query criteria used.

How did you fix this issue ?

Your filter and projection query should be in this format:

Bson queryFilter = in(“countries”, country);
Bson projection = new Document(“title”, 1);

The “in” operator is key.

1 Like

[L String error can be done away by not passing String… country directly,

use Arrays.asList(country), this will convert the county as a list.