0

I have a JSF application using PrimeFaces 6.2 and Spring 5.1.4. I read, that an exception handler can be defined in the faces-config.xml like this:

<factory>
    <exception-handler-factory>my.package.MyExceptionHandlerFactory</exception-handler-factory>
</factory>

I wondered how I could get the dependencies injected into an ExceptionHandlerFactory and ExceptionHandler?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113

1 Answers1

2

You can't do this out of the box. It would be possible by creating an "spring aware" ExceptionHandlerFactory and create the ExceptionHandler instance via Spring but i would just get the beans manually in your ExceptionHandler like: Best way to manually pull a spring bean?

tandraschko
  • 2,291
  • 13
  • 13
  • Yep thanks. I have already crated a solution, where in the handle method in my handler I simply let the spring context inject the dependencies on first use. The injection itself is as simple as FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance()).getAutowireCapableBeanFactory().autowireBean(this) – Gábor Lipták Apr 08 '19 at 07:37