Q:

does not have a corresponding accessor for data binding Play framework 2.5.3

I want to save user data to database. play version 2.5.3
I am getting this error:

JSR-303 validated property 'first_name' does not have a corresponding accessor for data binding - check your DataBinder's
  configuration (bean property versus direct field access)]

My model class
@Entity
public class UserRegisterModel extends Model
{
    @Id
    @GeneratedValue
    protected Long ID;

    @Constraints.Required
    protected String first_name;
    protected String last_name;
    protected String user_name;

    @Constraints.Required
    protected String password;
    protected String password_confirmation;

    @Constraints.Email
    @Column(unique = true)
    protected String email;
}

Controller class
public Result submitUserRegistrationForm()
{
    play.data.Form<UserRegisterModel> form = play.data.Form.form(UserRegisterModel.class).bindFromRequest();
    UserRegisterModel register = form.bindFromRequest().get();
}

Also I want to match password and conform password. I should do this in Model or controller.
Could you please provide me some sample code(Model,Controller) with form validation?

A:

As discussed at the comments, you have to add play-enhancer as documented here:
https://www.playframework.com/documentation/2.5.x/PlayEnhancer#Setting-up
Also, the enhancer just works under the following conditions:

The enhancer looks for all fields on Java classes that:

are public
are non static
are non final

For each of those fields, it will generate a getter and a setter if they don’t already exist. If you wish to provide a custom getter or setter for a field, this can be done by just writing it, the Play enhancer will simply skip the generation of the getter or setter if it already exists.

So, you have two options here: keep the fields protected and write your own getters and setters or made the public and let the enhancer generate getters and setters required by other libraries (like form binding).

