ozkanpakdil
ozkanpakdil

Reputation: 4602

vertx build with graalvm

I fallowed https://github.com/vertx-howtos/graal-native-image-howto/blob/20.3.0/README.adoc and manage to build my vertx project with graalvm, but when I start the native image vertx is not starting. I can not see vertx logs, "listening on..."

You can see my full pom here

And java code here

Upvotes: 0

Views: 755

Answers (1)

Paulo Lopes
Paulo Lopes

Reputation: 5801

Adding some error handling to the application will show that the 1st problem is related to missing the file application.properties from the image, this can be fixed by updating the native-image.properties config with:

-H:IncludeResources=.*\\.properties

Then the application will start but again will fail to return data. This is because the application is using jackson databind (which relies on reflection) to encode the POJO to JSON.

Fixing it requires some understanding on how jackson reflection works and write the correct configuration, or just keep it simple and use Vert.x built in JSON types, for example:

        req.response()
         .putHeader("content-type", "application/json")
         .end(new JsonObject()
           .put("name", "vertx")
           .put("releaseYear", LocalDate.now().getYear())
           .encode());

Upvotes: 1

Related Questions