Reputation: 127
I'm trying to use a custom deserializer in Jackson to deserialize some json objects. However, when I try to have the ObjectMapper read the json, the following exception occurs:
java.lang.IllegalStateException: AnnotationIntrospector returned Class com.Geometry.GeometryDeserializer; expected Class<JsonDeserializer>
I'm somewhat at a loss of what to do here, since it seems like the AnnotationIntrospector is complaining that my GeometryDeserializer is not a subclass of JsonDeserializer, when it clearly is.
Here's where I create the Object Mapper:
public void deserializeJson(String json) {
ObjectMapper mapper = new ObjectMapper();
mapper.addMixInAnnotations(Feature.class, MixIn.class);
Feature feature = mapper.readValue(json, Feature.class);
}
...my Mix In class:
abstract class MixIn {
@JsonDeserialize(using=GeometryDeserializer.class)
abstract void setGeometry(Geometry geometry);
}
...and my deserializer:
public class GeometryDeserializer extends JsonDeserializer<Geometry> {
@Override
public Geometry deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
//stuff happens
}
}
Any feedback/assistance would be greatly appriciated.
Thanks.
Upvotes: 0
Views: 1248
Reputation: 116522
Wild guess: you are accidentally mixing up Jackson 1.x and Jackson 2.x types? Class names are mostly the same, but live in different packages -- things work when using one set of classes, but IDEs may cause accidental mix-ups.
Upvotes: 0