0

Have this code inside ControllerAdvice:

@ExceptionHandler(value = Exception.class)
@ResponseStatus(value = INTERNAL_SERVER_ERROR)
protected ResponseEntity<ApiError> handleAnyException(Exception ex, WebRequest request) {

for custom exception and BindingException.class in the same ControllerAdvice the ex.getMessage() is not null.

Running the application not with spring graalVM native image also works fine and for Exception class ex.getMessage() is not null as well.

But running the app on spring native image the ex.getMessage() is null only for the Exception.class handler.

What can be the reason for this different behavior ?

xMilos
  • 1,519
  • 4
  • 21
  • 36
  • this sounds like reflection issue, you can try to generate json configuration with agent from command line then put those json files to appropriate folder and build native, check my [ktor example](https://ozkanpakdil.github.io/graalvm,java,ktor,native-image/2022/11/13/ktor-graal.html) same logic can apply to spring boot or anything. it would be easier if you provided a reproducer. – ozkanpakdil Jan 17 '23 at 19:05

0 Answers0