https://kotlinlang.org logo
Title
b

Bernhard

08/01/2018, 10:06 AM
I'd rather inject it though
m

marschwar

08/01/2018, 10:14 AM
Are you using
com.fasterxml.jackson.module:jackson-module-kotlin
? We simply inject the ObjectMapper and it works out of the box.
b

Bernhard

08/01/2018, 10:33 AM
yes val objectMapper: ObjectMapper, gives me org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Call is not yet supported for this function: public constructor `ElasticChangeLogRepository$FindChangelogsQuery$query$1`() defined in at.rwa.sws.location.changelog.repository.`ElasticChangeLogRepository$FindChangelogsQuery$query$1`[DeserializedClassConstructorDescriptor@36e3321e] (member = null) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1006) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866)
that's the class I'm serializing https://dpaste.de/FAyv
thats the full stack trace https://dpaste.de/y79J
looks like it tries to find an empty constructor for some reason
maybe the issue is that I'm not using a data class?
hm, jacksonObjectMapper() returns a mapper with only one configuration, the default mapper returns https://dpaste.de/PESY
maybe some module breaks some things
h

hho

08/01/2018, 12:09 PM
All pastes are expired. 🤷‍♂️
You can post stuff here enclosed in triple backticks - or via the big in front of the input line.
b

Bernhard

08/01/2018, 12:49 PM
Can't make snippets in this thread it seems
and things are too long
class FindChangelogsQuery(date: String, offset: Int, size: Int) { val query = object { val bool = object { val must = object { val range = object { val timestamp = object { val gte = date val format = "yyyy-MM-dd'T'HH🇲🇲ssZ" } } } } } val sort = object { val timestamp = object { val order = "asc" } } val from = offset.toString() val size = size.toString() }
thats the object
that's how I serialize it:
fun buildQuery(date: Date, offset: Int, size: Int): String {
        val formattedDate = formatHolder.get().format(date)
        val query = FindChangelogsQuery(formattedDate, offset, size)
        return objectMapper.writeValueAsString(query)
    }