ManuPanu
ManuPanu

Reputation: 217

Global JSF exception handler with CDI injection

I'm currently able to catch all exceptions with and a custom exception handler like described here:

JSF 2 Global exception handling, navigation to error page not happening

I'm making extensive use of CDI injection and wan't to call methods for email sending and error logging based on some database lookups. Everything is implemented in CDI Beans and I'm not able to call them within my exception handler. Do you know any way to accomplish calling them or are there any workarounds?

Upvotes: 2

Views: 1000

Answers (3)

Adrian Jałoszewski
Adrian Jałoszewski

Reputation: 1723

The solution is to inject the beans into the ExceptionHandlerFactory and pass them to the ExceptionHandlerWrapper by manually calling setters or adding another constructor parameter to it. Tested on Websphere 9.0 with JEE 7.

Upvotes: 0

You need inject o CustomExceptionHandler in then CustomExceptionHandlerFactory. Only then then the injections in CustomExceptionHandler will work

Upvotes: 0

faissalb
faissalb

Reputation: 1749

Deltaspike offers something that may help you accomplish this:

http://deltaspike.apache.org/documentation/jsf.html#_intergration_with_exception_control_from_deltaspike_0_6

Upvotes: 0

Related Questions