You are currently viewing [SOLVED] Android: org.modelmapper.ModelMapper – No serializer found for class…and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) – 1 min solution!
Photo by Johny vino on Unsplash
Could You Please Share This Post? I Appreciate It And Thank YOU! :) Have A Nice Day!
4.9
(2239)

Problem -> Android

You can encounter this problem when you use org.modelmapper.ModelMapper library and class. In most cases the issue is that you don’t provide the Constructors and/or Getters and Setters for you class.

Type definition error: [simple type, class com.bigdataetl.model.dto.PersonDto]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.bigdataetl.model.dto.PersonDto and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])",

Solution with Lombok

Using Lombok if you use these three annotations, Lombok provides Constructors, Getters and Setters.

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PersonDto {

    private String id;

    private String name;

    private int age;

}

Solution without Lombok

As you can see without Lombok you have to provide Constructors, Getters and Setters on your own. It’s not a convenient way. I encourage you to use Lombok in the future 🙂

public class PersonDto {

    private String id;

    private String name;

    private int age;

    public PersonDto(String id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public PersonDto() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

I hope I helped you solve the problem you encountered.

Could You Please Share This Post? 
I appreciate It And Thank YOU! :)
Have A Nice Day!

BigData-ETL: image 7YOU MIGHT ALSO LIKE

How useful was this post?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 2239

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?