Failure behaviour

After compiling an application as native image the command line property --management.endpoints.web.exposure.include="*" or even the system property -Dmanagement.endpoints.web.exposure.include="*" stop working.

Replay failure

To create the executable, run the following goal:

$ ./mvnw native:compile -Pnative

Then, you reproduce the failure behaviour like this:

$ ./target/spring-native-actuator --management.endpoints.web.exposure.include="*"

Just exposing one endpoint:

2024-02-14T16:06:29.315+01:00  INFO 64940 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 21 ms
2024-02-14T16:06:29.350+01:00  INFO 64940 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2024-02-14T16:06:29.353+01:00  INFO 64940 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''

Example Project

see: https://github.com/mixaaaa/spring-native-actuator

Comment From: wilkinsona

This is to be expected. When using Graal, if you want an endpoint to be exposed at runtime, it must be exposed at build time otherwise it's optimised out of the native image and cannot then be exposed. Please see https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.introducing-graalvm-native-images.key-differences-with-jvm-deployments and https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.introducing-graalvm-native-images.understanding-aot-processing for further details on the limitations of Graal.

Comment From: mixaaaa

Yes, thanks @wilkinsona. After getting the point I completely acknowledge. At the end for a longtime spring boot user it just feels completely unnatural, to get this behavior, because of decades of maximum freedom at every small configuration.

To add hints at properties-documentation (example: https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.exposing) would maybe just go beyond the scope?