Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So I have a simple object:

public class State {
    private DateTime time;
    private Map<String, Object> map;

    ....
}

I'm using default typing and a custom serializer/deserializer in the ObjectMapper as follows:

SimpleModule module = new SimpleModule("Serialization", new Version(1, 0, 0, null))
                          .addSerializer(DateTime.class, new DateTimeSerializer())
                          .addDeserializer(DateTime.class, new DateTimeDeserializer());

ObjectMapper mapper = new ObjectMapper()
                          .registerModule(module)
                          .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
                          .enableDefaultTyping(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, JsonTypeInfo.As.WRAPPER_ARRAY);

The DateTime field, sitting directly in the object, serializes using my serializer. And primitive types within the map also serialize correctly, utilising type information in a wrapper array where necessary to preserve the type. However, If I put my custom type (DateTime) into the map and try to serialize, I hit the following issue:

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Type id handling not implemented for type org.joda.time.DateTime (through reference chain: State["map"]->...HashMap["DateTime1"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:232)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:197)
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:184)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeTypedFields(MapSerializer.java:488)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:354)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithType(MapSerializer.java:334)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithType(MapSerializer.java:27)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:571)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:597)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:569)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:597)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:142)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118)
at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:2718)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:2210)
at com.rbs.agile.strategy.strategymanager.store.mongo.internal.JacksonDBObjectConverter.toDBObject(JacksonDBObjectConverter.java:26)
... 32 more

Caused by: java.lang.UnsupportedOperationException: Type id handling not implemented for type org.joda.time.DateTime
    at com.fasterxml.jackson.databind.JsonSerializer.serializeWithType(JsonSerializer.java:142)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeTypedFields(MapSerializer.java:484)
    ... 45 more
share|improve this question
    
I'm having the same problem here. Any progress with this? –  Simon André Forsberg Oct 21 '13 at 16:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.