[Solved] JSON parse error: (was java.lang.NullPointerException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain:

[Solved] JSON parse error: (was java.lang.NullPointerException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain:

Full Exception:

{"timestamp":"2018-09-21T12:25:44.365+0000","status":400,"error":"Bad Request","message":"JSON parse error: (was java.lang.NullPointerException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: com.ngdeveloper.entities.Coupon[\"store\"]->com.ngdeveloper.entities.Store[\"description\"])","path":"/ngdeveloper/api/rest/coupon/add"}

Solution for com.fasterxml.jackson.databind.JsonMappingException:

By default jackson tries to serialize the class as well as all the fields of the class, so you could have got the null pointer exception.

Add @JsonIgnore to your getter method, here I resolved like this,

@JsonIgnore
public Set<Description> getDescription() {
	return description;
}

Leave a Reply