1

Is there a way to let my custom ExceptionHandler annoted with @ControllerAdvice manage exceptions thrown in a JSF controller?

I noticed that all exceptions thrown in @PostConstruct methods won't get caught by the @ControllerAdvice class, instead JSF built in exception handler manage them.

I'm aware that I can extend ExceptionHandlerFactory, but all the guides I found are outdated and it's not clear if I can use it for the functionality I need.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
pak1989
  • 11
  • 2
  • PostContruct methods triggered on app startup. Quite probably your ExceptionHandlers are not initialized by Spring. And why do you want to catch in handler start up annotations? – Danila Zharenkov Jun 16 '21 at 08:04
  • Spring `ExceptionHandler` will work for controllers/handlers executed in the context of a Spring `DispatcherServlet` this is not the case with JSF so this will not work, unless you place JSF behind the `DispatcherServlet`, but that would complicate things only. – M. Deinum Jun 16 '21 at 08:35
  • @DanilaZharenkov **@ControllerAdvice** is working properly, for example if I try to go to a path that is not mapped in any controller, it catches the exception. Only if I'm in a JSF controller my ExceptionHandler won't get called. – pak1989 Jun 16 '21 at 08:53

0 Answers0