-
I have Micronaut inject its Jackson ObjectMapper into one of my singletons, and then call ObjectMapper#readValue(String, Class) to deserialize the class listed below. This works fine in a normal JVM, but in a GraalVM native image this results in the following exception:
Any ideas what is causing this, and how it can be fixed?
Edit: In my original question these fields were declared final, based on my expectation that Jackson would follow the getBasicRestConnectionConfig() method to set the properties on the existing instance like some other frameworks would do. I have since found out that Jackson doesn't do this (except for Maps and Collections if |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yet again answering my own question; the problem wasn't in this class but in another class that includes this class as a field. Basically the structure was like this:
I was assuming that this error was related to Class2, as the exception seemed to reference the fieldForClass3 field/methods defined in that class. However, I forgot to add Question remains of course why behavior is different between native image and JVM-based run... |
Beta Was this translation helpful? Give feedback.
Yet again answering my own question; the problem wasn't in this class but in another class that includes this class as a field. Basically the structure was like this:
I was assuming that this error was related to Class2, as the exception seemed to reference the fieldForClass3 field/methods defined in that class.
However, I forgot to add
@JsonIgnore
to Class1#getFieldForClass3(), so basically Jackson was serializing my Class3 twice; once as part of Class1 and once as part of Class2. When trying to deserialize, Jackson…