micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

Jackson deserialization doesn't work in Kotlin using GraalVM

Open adrienpessu opened this issue 2 years ago • 2 comments

Expected Behavior

The deserialization works with a JDK ./gradlew run but when I run it with GraalVM ./gradlew nativeRun I get the error :

Caused by: io.micronaut.http.codec.CodecException: Error decoding stream for type [class net.pessu.ifconfig.IfConfig]: Cannot construct instance of `com.example.ifconfig.IfConfig` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

Actual Behaviour

It should deserialize

Steps To Reproduce

I do have a POC in a Github repository

My data class looks like this :

data class IfConfig(
  @JsonProperty("ip") val ip: String = "",
  @JsonProperty("ip_decimal") val ip_decimal: Long = 0L,
  @JsonProperty("country") val country: String = "",
  @JsonProperty("country_iso") val country_iso: String = "",
  @JsonProperty("country_eu") val country_eu: Boolean = true,
  @JsonProperty("region_name") val region_name: String = "",
  @JsonProperty("region_code") val region_code: String = "",
  @JsonProperty("zip_code") val zip_code: String = "",
  @JsonProperty("city") val city: String = "",
  @JsonProperty("latitude") val latitude: Double = 0.0,
  @JsonProperty("longitude") val longitude: Double = 0.0,
  @JsonProperty("time_zone") val time_zone: String = "",
  @JsonProperty("asn") val asn: String = "",
  @JsonProperty("asn_org") val asn_org: String = ""
)

Environment Information

  • Mac M1 Max, MacOs 12.4
  • java 22.1.0.r17-grl

Example Application

https://github.com/adrienpessu/poc-injection-native

Version

3.5.2

adrienpessu avatar Jul 07 '22 09:07 adrienpessu

try making the class @ReflectiveAccess. the bean introspection module doesn't have kotlin support yet

yawkat avatar Jul 11 '22 08:07 yawkat

It works with @ReflectiveAccess. Thank you @yawkat

adrienpessu avatar Jul 11 '22 08:07 adrienpessu