question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong type Exception when changing the order of @JsonSubTypes annotation

See original GitHub issue

Thank you for the excellent library. Unfortunately I am having some trouble when using a more complex structure. Here is a minimal Example:

Given the following hierarchy:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
		@JsonSubTypes.Type(Line.class),
		@JsonSubTypes.Type(Pt.class) })
public static class Loc  {
}
@JsonSubTypes({
		@JsonSubTypes.Type(Abs.class)
})
public static class Pt extends Loc {
}
public static class Abs extends Pt {
}
public static class Line extends Loc {
	public List<Pt>attr;
}

the generator throws the exception Wrong type - working on [simple type, class com.example.Pt] - got [simple type, class com.example.Abs] when calling ‘generator.generateJsonSchema(Loc.class);’

When changing the order of the subtype annotation on Loc to

@JsonSubTypes({
		@JsonSubTypes.Type(Pt.class),
		@JsonSubTypes.Type(Line.class) })

everything works. Unfortunately in our POJOs we cannot modify all of subtype annotations to ensure that there is no backward dependency between them. Is this something that is easy to fix?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alessiostallacommented, Jun 4, 2021

I have the same issue.

0reactions
NBaucommented, Jan 23, 2020

Is my PR #109 not sufficient? I am sorry, I tried to mimic the style of the other tests, but I am not sure how it is supposed to work,

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - De-serializing JSON to polymorphic object model using ...
Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type")" as annotation with your Interface. You can also define the order of properties when mapper ...
Read more >
Deserialization of `@JsonTypeInfo` annotated type fails with ...
When attempting to deserialize to a concrete class that is part of a polymorphic type hierarchy, an InvalidTypeIdException is thrown if the ...
Read more >
FasterXML/jackson-databind - Gitter
I've recently upgraded from Jackson 2.9.10 to 2.10.0 and notice a change in how Iterator ... VerifyError: Bad return type Exception Details: Location: ......
Read more >
Jackson Exceptions - Problems and Solutions - Baeldung
The most common Jackson exceptions - the cause of the problem and the ... with a simple annotation — @JsonDeserialize on the abstract...
Read more >
SUSE alert SUSE-SU-2022:1678-1 (jackson-databind ...
_appendSourceDesc()' + Add 'StreamWriteException' type to ... "currentValue" wrongly references to '@JsonTypeInfo' annotated object + DOM ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found