Total Pageviews

2013/11/12

How to fix com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException

Exception
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "reportName" (class gov.nta.ets.web.dto.Ets405rFormBean), not marked as ignorable (4 known properties: , "accYy", "type", "data", "funcId"])
 at [Source: java.io.ByteArrayInputStream@57a9b75a; line: 4, column: 18] (through reference chain: gov.nta.ets.web.dto.Ets405rFormBean["reportName"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79) [jackson-databind-2.2.3.jar:]

Root Cause
This exception means that there are get and set methods of an object in your class and Jackson is unable to figure out during serialization and deserialization process.

Solution
Apply @JsonIgnore on getter method, i.e. getReportName
1:   /**  
2:     * Gets the report name.  
3:     *   
4:     * @return the reportName  
5:     */  
6:    @JsonIgnore  
7:    public String getReportName() {  
8:      return reportName;  
9:    }  

No comments: