title: A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type
body: <p><strong>UserProfileModel has two embedded models. I am giving here concisely:</strong></p>
  
  <pre><code>@Document(collection = "USER_PROFILE")
  public class UserProfileModel extends BaseModel&lt;UserModel&gt;  {
  
      public static final String FIELD_USER_ID = "userId";
      public static final String FIELD_BASIC_INFO = "basicInfo";
      public static final String FIELD_CONTACT_INFO = "contactInfo";
  
      private String userId;
      private BasicInfo basicInfo;
      private ContactInfo contactInfo;
  }
  
  public class BasicInfo {
      private String gender;
      private LocalDate birthDate;
      private String[] langs;
      private String religiousView;
      private String politicalView;
  }
  
  public class ContactInfo {
      private String[] mobilePhones;
      private Address address;
      private SocialLink[] socialLinks;
      private String[] websites;
      private String[] emails;
  }
  </code></pre>
  
  <p><strong>Writing converter class of UserProfileModel:</strong></p>
  
  <pre><code>@Component
  @WritingConverter
  public class UserProfileModelConverter implements Converter&lt;UserProfileModel, Document&gt; {
  
      @Override
      public Document convert(UserProfileModel s) {
          Document doc = new Document();
  
          if (null != s.getUserId())
              doc.put(UserProfileModel.FIELD_USER_ID, s.getUserId());
  
          if (null != s.getBasicInfo())
              doc.put(UserProfileModel.FIELD_BASIC_INFO, s.getBasicInfo());
  
          if (null != s.getContactInfo())
              doc.put(UserProfileModel.FIELD_CONTACT_INFO, s.getContactInfo());
      }
  }
  </code></pre>
  
  <p><strong>Trying to save an object of UserProfileModel like this:</strong></p>
  
  <pre><code>@Autowired
  private UserProfileRepository repo;
  
  UserProfileModel profileModel = generateUserProfileModel();
  repo.save(profileModel);
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when encoding using the AutomaticPojoCodec.
  Encoding a BasicInfo: 'BasicInfo(gender=Male, birthDate=2020-05-05, langs=[Lang 1, Lang 2], religiousView=Islam (Sunni), politicalView=N/A)' failed with the following exception:
  
  Failed to encode 'BasicInfo'. Encoding 'langs' errored with: Can't find a codec for class [Ljava.lang.String;.
  
  A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.
  
      at org.bson.codecs.pojo.AutomaticPojoCodec.encode(AutomaticPojoCodec.java:53)
      at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
      at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:185)
      at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
      at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:141)
      at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
      at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
      at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
  </code></pre>
  
  <hr>
  
  <p>If I don't use converter for <code>UserProfileModel</code> by adding in Mongo Config, then this exception doesn't appear and everything works well. </p>
  
  <p>But I am trying to use the Converter class for some reason. </p>
  
  <p>So is it something wrong or modification needed in converter class? </p>