Home

Serializing Failures

21/01/2023

My initial success with lambda-kotlin-request-router has come to crashing end. While I was able to use the library for the simplest of calls, as soon as I started a 'real world' example (fetching my project structure class), it failed with a serialization error.

My structure class uses the kotlinx.datetime library to manage dates, but the router library is using a serialization framework called Jackson which, by default, doesn't understand that date format (even though it uses the underlying java.time classes on the JVM). As I'm unfamiliar with Jackson, I thought I'd try converting it to use kotlinx.serialization instead, a framework I'm more familiar with.

Attempting to make that change has been very painful, to the point of failure. It's very hard to retrofit a library someone else to wrote to make it work the way I would like. I'm not even sure converting Cantilever to Jackson instead of kotlinx.serialization would help, and that's not an approach I want to take anyway.

Just for reference, here's the error message:

"errorMessage": "Java 8 date/time type `java.time.LocalTime` not supported by default: add Module \"com.fasterxml.jackson.datatype:jackson-datatype-jsr310\" to enable handling (through reference chain: org.liamjd.cantilever.api.controllers.Result$Success[\"value\"]->org.liamjd.cantilever.models.Structure[\"layouts\"]->org.liamjd.cantilever.models.Layouts[\"templates\"]->java.util.LinkedHashMap[\"templates/post.html.hbs\"]->org.liamjd.cantilever.models.Template[\"lastUpdated\"]->kotlinx.datetime.LocalDateTime[\"time\"]->kotlinx.datetime.LocalTime[\"value$kotlinx_datetime\"])",
  "errorType": "com.fasterxml.jackson.databind.exc.InvalidDefinitionException",

I think my experiments with lambda-kotlin-request-router have come to an end. I'm not sure what the next step is, except maybe writing my own router inside Cantilever "inspired" by this library?

It has been said (by me) that I'm putting off writing any sort of UI work, and while there is some truth in that, any UI needs an API to call. No router, no API. No serialization, no router.

The only other task I think I could work on for Cantilever would be building an index.html file and navigation functions, and I'm really not sure how I'm going to start that yet.

Prev: Forking a library Next: Serialization Progress