Here is my best attempt at a minimal example:
class YamlScratch {
private static final String YAML_CONTENT = "" +
"foo: &foo\n" +
" value: bar\n" +
"boo: *foo\n";
public static void main(String[] args) throws Exception {
ScratchModel yamlScratch = new ObjectMapper(
new YAMLFactory()
).readValue(YAML_CONTENT, ScratchModel.class);
System.out.printf("foo = %s, boo=%s%n", yamlScratch.foo, yamlScratch
.boo);
}
@JsonIdentityInfo(generator = ObjectIdGenerators.None.class)
public static class ScratchModel {
@JsonProperty("foo")
StringHolder foo;
@JsonProperty("boo")
StringHolder boo;
}
@JsonIdentityInfo(generator = ObjectIdGenerators.None.class)
public static class StringHolder {
@JsonProperty("value")
String value;
@Override
public String toString() {
return value;
}
}
}
Output:
Exception in thread "main" com.fasterxml.jackson.databind.exc.
MismatchedInputException: Cannot construct instance of
`YamlScratch$StringHolder` (although at least one Creator exists): no String
-argument constructor/factory method to deserialize from String value ('foo'
)
at [Source: (StringReader); line: 3, column: 6] (through reference chain:
YamlScratch$ScratchModel["boo"])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(
MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.
reportInputMismatch(DeserializationContext.java:1329)
at com.fasterxml.jackson.databind.DeserializationContext.
handleMissingInstantiator(DeserializationContext.java:1031)
at com.fasterxml.jackson.databind.deser.ValueInstantiator.
_createFromStringFallbacks(ValueInstantiator.java:370)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.
createFromString(StdValueInstantiator.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.
deserializeFromString(BeanDeserializerBase.java:1351)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.
_deserializeOther(BeanDeserializer.java:170)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(
BeanDeserializer.java:161)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.
deserializeAndSet(FieldProperty.java:136)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.
vanillaDeserialize(BeanDeserializer.java:287)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(
BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(
ObjectMapper.java:4001)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.
java:2992)
at YamlScratch.main(scratch_8.java:17)
Attached screenshot shows Jackson libraries and versions being referenced -
short version is that everything is 2.9.1, but jackson-annotations for some
reason is 2.9.0. This doesn't seem to stop any other Jackson functionality
from working, so I suspect it is not the problem, but I'm highlighting it
for you just in case.
--
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.