@JsonTypeInfo(use=JsonTypeInfo.Id.MINIMAL_CLASS, include=JsonTypeInfo.As.PROPERTY, property="type")

478 views
Skip to first unread message

Benson Margulies

unread,
Aug 13, 2014, 5:12:38 PM8/13/14
to jackso...@googlegroups.com
I'm a bit bewildered.

I have the subject annotation on an abstract class.

I'm trying to read a YAML file that has a type property, but no polymorphic processing seems to be happening.

I've explicitly declared 'type' as a property of the abstract class; it's a constructor arg with
@JsonProperty("type").

I get...

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Could not find creator property with name 'type' (in class com.basistech.wsbus.config.Reporting)
 at [Source: java.io.BufferedInputStream@4b7689bc; line: 5, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:757)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:579)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:270)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:168)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:399)



Tatu Saloranta

unread,
Aug 16, 2014, 4:39:26 PM8/16/14
to jackso...@googlegroups.com
It'd be necessary to see the whole bean. Exception message as is does not right a bell. Or, stand-alone unit test would be the best option of course, if it's possible to isolate.

-+ Tatu +-


--
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 jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benson Margulies

unread,
Aug 16, 2014, 5:19:49 PM8/16/14
to jackso...@googlegroups.com

I was trying to use a constructor with a jsoncreator annotation. When I switched to fields all was well.

Tatu Saloranta

unread,
Aug 19, 2014, 9:16:08 PM8/19/14
to jackso...@googlegroups.com
Ok. Let me know if problem re-surfaces, sounds like some kind of discrepancy that should not exist. But glad that you were able to work around it.

-+ Tatu +-

Benson Margulies

unread,
Aug 19, 2014, 9:24:02 PM8/19/14
to jackso...@googlegroups.com
On Tue, Aug 19, 2014 at 9:16 PM, Tatu Saloranta <tsalo...@gmail.com> wrote:
Ok. Let me know if problem re-surfaces, sounds like some kind of discrepancy that should not exist. But glad that you were able to work around it.

Somewhere on one of your pages I found advice not to try to combine polymorphism and @JsonCreator :-) 

Tatu Saloranta

unread,
Aug 22, 2014, 2:43:58 PM8/22/14
to jackso...@googlegroups.com
Correct, that combination has proven challenging due to multiple reasons.

-+ Tatu +-
Reply all
Reply to author
Forward
0 new messages