I've spent several days puzzling over this error message and am not finding a solution. I think what's happening is Jackson, while serializing some JSON, is choosing the wrong object class for something or other.
The error is pasted below. If I understand the error correctly it is calling WeatherHistoricalProfile.setMeasurementMetaData with an EnergyMeasurementMetaData when for that method it should have a WeatherMeasurementMetaData object instead. If so, that's obviously incorrect, but I don't understand why that would be so. This occurs during the final stage of a POST that creates a large sprawling object tree in a Spring Boot app that uses Hibernate/JPA for persistence. Jackson 2.8.9 is used for JSON to/from the REST API calls. The objects shown here are part of the object tree. I have inspected the data going into the call -- Jackson properly parsed the incoming JSON and correctly assigned it to the correct objects. The data gets written to the database. The final step sending a JSON back to the caller showing what got persisted. This occurs during the creation of that JSON. Just before this my code prints out the data structures and they are correct. I have posted more details including the class definitions on Stack Overflow: https://stackoverflow.com/questions/46750645/org-springframework-http-converter-httpmessagenotwritableexception-could-not-wr One thing I'm hoping for is an explanation of this error message. 2017-10-15 13:33:44.999 WARN 59655 --- [nio-8080-exec-4] > .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: > org.springframework.http.converter.HttpMessageNotWritableException: Could > not write JSON: Could not set field value [class EnergyMeasurementMetaData { > class MeasurementMetadata { > accumulationCharacteristic: null > dataQualifier: null > description: null > itemDescription: null > itemUnits: null > measurementQuality: null > resolution: null > siScaleCode: null > } measuringPeriod: null > energyDataKind: null > }] value by reflection : [class > com.amzur.orangebuttonapi.model.measurementsets.WeatherHistoricalProfile.measurementMetaData] > > setter of > com.amzur.orangebuttonapi.model.measurementsets.WeatherHistoricalProfile.measurementMetaData; > > nested exception is com.fasterxml.jackson.databind.JsonMappingException: > Could not set field value [class EnergyMeasurementMetaData { > class MeasurementMetadata { > accumulationCharacteristic: null > dataQualifier: null > description: null > itemDescription: null > itemUnits: null > measurementQuality: null > resolution: null > siScaleCode: null > } measuringPeriod: null > energyDataKind: null > }] value by reflection : [class > com.amzur.orangebuttonapi.model.measurementsets.WeatherHistoricalProfile.measurementMetaData] > > setter of > com.amzur.orangebuttonapi.model.measurementsets.WeatherHistoricalProfile.measurementMetaData > > (through reference chain: > java.util.LinkedList[0]->com.amzur.orangebuttonapi.model.system.PVSystem["weatherProfiles"]) -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
