Skip to content

Instantly share code, notes, and snippets.

@daviddenton
Last active April 14, 2018 10:17
Show Gist options
  • Save daviddenton/154aab8d3391ec7faaf1c8d0ffc62159 to your computer and use it in GitHub Desktop.
Save daviddenton/154aab8d3391ec7faaf1c8d0ffc62159 to your computer and use it in GitHub Desktop.
package org.http4k.testing
import org.http4k.core.Body
import org.http4k.core.Method.GET
import org.http4k.core.Request
import org.http4k.format.Gson.auto
data class MyDataClass(val s: String)
fun main(args: Array<String>) {
Body.auto<MyDataClass>().toLens()(Request(GET, "/"))
}
Exception in thread "main" org.http4k.lens.LensFailure: body 'body' must be object
at org.http4k.lens.BodyLens.invoke(body.kt:23)
at org.http4k.testing.LensKt.main(lens.kt:11)
Caused by: java.lang.IllegalArgumentException: Instantiation of [simple type, class org.http4k.testing.MyDataClass] value failed for JSON property s due to missing (therefore NULL) value for creator parameter s which is a non-nullable type
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: org.http4k.testing.MyDataClass["s"])
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3738)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3656)
at org.http4k.format.ConfigurableJackson.asA(Jackson.kt:74)
at org.http4k.testing.LensKt$main$$inlined$auto$1.invoke(Jackson.kt:92)
at org.http4k.testing.LensKt$main$$inlined$auto$1.invoke(Jackson.kt:27)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:227)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:16)
at org.http4k.lens.LensGet$invoke$1.invoke(lensSpec.kt:17)
at org.http4k.lens.LensGet$invoke$1.invoke(lensSpec.kt:16)
at org.http4k.lens.BiDiBodyLensSpec$toLens$1.invoke(body.kt:80)
at org.http4k.lens.BiDiBodyLensSpec$toLens$1.invoke(body.kt:62)
at org.http4k.lens.BodyLens.invoke(body.kt:19)
... 1 more
Caused by: com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class org.http4k.testing.MyDataClass] value failed for JSON property s due to missing (therefore NULL) value for creator parameter s which is a non-nullable type
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: org.http4k.testing.MyDataClass["s"])
at com.fasterxml.jackson.module.kotlin.KotlinValueInstantiator.createFromObjectWith(KotlinValueInstantiator.kt:53)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:195)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:488)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1280)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3733)
... 12 more
Exception in thread "main" org.http4k.lens.LensFailure: body 'body' must be object (InvalidJsonException: Could not convert to a JSON Object or Array. )
at org.http4k.lens.BodyLens.invoke(body.kt:23)
at org.http4k.testing.LensKt.main(lens.kt:11)
Caused by: org.http4k.format.InvalidJsonException: Could not convert to a JSON Object or Array.
at org.http4k.format.ConfigurableGson.asJsonObject(Gson.kt:42)
at org.http4k.format.ConfigurableGson.asJsonObject(Gson.kt:21)
at org.http4k.format.Json$DefaultImpls.parse(Json.kt:65)
at org.http4k.format.JsonLibAutoMarshallingJson.parse(AutoMarshallingJson.kt:15)
at org.http4k.format.Json$body$3.invoke(Json.kt:73)
at org.http4k.format.Json$body$3.invoke(Json.kt:22)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:227)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:16)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:19)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:16)
at org.http4k.lens.LensGet$invoke$1.invoke(lensSpec.kt:17)
at org.http4k.lens.LensGet$invoke$1.invoke(lensSpec.kt:16)
at org.http4k.lens.BiDiBodyLensSpec$toLens$1.invoke(body.kt:80)
at org.http4k.lens.BiDiBodyLensSpec$toLens$1.invoke(body.kt:62)
at org.http4k.lens.BodyLens.invoke(body.kt:19)
... 1 more
Exception in thread "main" org.http4k.lens.LensFailure: body 'body' must be object
at org.http4k.lens.BodyLens.invoke(body.kt:23)
at org.http4k.testing.LensKt.main(lens.kt:11)
Caused by: org.http4k.format.InvalidJsonException: Could not convert to a JSON Object or Array.
at org.http4k.format.ConfigurableGson.asJsonObject(Gson.kt:42)
at org.http4k.format.ConfigurableGson.asJsonObject(Gson.kt:21)
at org.http4k.format.Json$DefaultImpls.parse(Json.kt:65)
at org.http4k.format.JsonLibAutoMarshallingJson.parse(AutoMarshallingJson.kt:15)
at org.http4k.format.Json$body$3.invoke(Json.kt:73)
at org.http4k.format.Json$body$3.invoke(Json.kt:22)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:227)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:16)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:19)
at org.http4k.lens.LensGet$map$1.invoke(lensSpec.kt:16)
at org.http4k.lens.LensGet$invoke$1.invoke(lensSpec.kt:17)
at org.http4k.lens.LensGet$invoke$1.invoke(lensSpec.kt:16)
at org.http4k.lens.BiDiBodyLensSpec$toLens$1.invoke(body.kt:80)
at org.http4k.lens.BiDiBodyLensSpec$toLens$1.invoke(body.kt:62)
at org.http4k.lens.BodyLens.invoke(body.kt:19)
... 1 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment