UnrecognizedPropertyException: Unrecognized field not marked as ignorable at Source: org.apache.catalina.connector.CoyoteInputStream@14ec141
I can make following observations after looking at GroupMemberMap
Class:
- Constructor is missing.
- Getter-Setter for the
UserId
is incorrect.
Also, you can add optional @JsonIgnoreProperties
to ignore all other unknown fields.
Here is the corrected code snippet:
package com.tazligen.model;@XmlRootElement@JsonIgnoreProperties(ignoreUnknown = true)public class GroupMemberMap { @JsonProperty("userId") private String userId; @JsonProperty("groupId") private String groupId; /* Add Constructor */ public GroupMemberMap() {} /* Corrected Name */ public String getUserId() { return userId; } /* Corrected Name */ public void setUserId(String userId) { this.userId = userId; } public String getGroupId() { return groupId; } public void setGroupId(String groupId) { this.groupId = groupId; } }
I was using lombok to generate getters and setters with @Getter and @Setter annotation. Now what solved a similar issue for me was converting data type of a field from primary java type boolean to Boolean. Lombok only generated a getter for it only if I used Boolean fieldName.
Just modify userId and groupId public
. By default, Jackson works on public member variables.
I think JsonIgnoreProperties is not solution as it is used to ignore whatever it doesn't recognize.
public String userId;public String groupId;