logbook icon indicating copy to clipboard operation
logbook copied to clipboard

Support native compilation with graalvm

Open itineric opened this issue 1 year ago • 6 comments

You could support graalvm native compilation. Currently it is not working, some exception occur: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.zalando.logbook.json.JsonHttpLogFormatter$JsonBody and no properties discovered to create BeanSerializer

Detailed Description

Define reflect-config.json files as explained in graalvm documentation.

Context

Can use logbook when going native

itineric avatar Oct 19 '23 16:10 itineric

In my case I was able to solve the problem in a Spring Boot application adding the following content into the file: src/main/resources/META-INF/native-image/org.zalando/logbook/reflect-config.json:

[
    {
      "name" : "org.zalando.logbook.json.JsonHttpLogFormatter$JsonBody",
      "allPublicMethods" : true
    }
]

Thanks @itineric for the tip.

jordanorc avatar Oct 25 '23 18:10 jordanorc

you can do that with only one step: rename your file reflection-config.json to reflect-config.json and place it inside src/main/resources/META-INF/native-image/<group id>/<artifact id> it will be picked up automatically.

It you are using Spring, you can also use ReflectionHints instead.

My point here is that this reflection config could be added directly to the logbook lib then no extra (external) configuration is required.

itineric avatar Oct 26 '23 06:10 itineric

@itineric, thanks for the tip. I updated the answer. My goal was to help those who are facing same problem, while the solution is not added directly to the logbook.

jordanorc avatar Oct 26 '23 09:10 jordanorc

Looks like a nice addition to logbook. @itineric would you be interested in contributing to the library to add the necessary changes?

kasmarian avatar Oct 27 '23 11:10 kasmarian

In order to prioritize the support for Logbook, we would like to check whether the old issues are still relevant. This issue has not been updated for over six months.

  • Please check if it is still relevant in latest version of the Logbook.
  • If so, please add a descriptive comment to keep the issue open.
  • Otherwise, the issue will automatically be closed after a week.

github-actions[bot] avatar Apr 29 '24 01:04 github-actions[bot]

Could be something that we look into in the future. Let's not close the issue yet.

msdousti avatar Apr 29 '24 16:04 msdousti