Add a custom Exception handler factory in faces-config.xml
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>
<factory>
<exception-handler-factory>com.fetchinglife.domain.web.permissions.CustomExceptionHandlerFactory</exception-handler-factory>
</factory>
Create custom exception handler factory
public class CustomExceptionHandlerFactory extends ExceptionHandlerFactory{
private ExceptionHandlerFactory wrapped;
public CustomExceptionHandlerFactory(ExceptionHandlerFactory wrapped) {
this.wrapped = wrapped;
}
@Override
public ExceptionHandler getExceptionHandler() {
return new CustomExceptionHandler(wrapped.getExceptionHandler());
}
@Override
public ExceptionHandlerFactory getWrapped() {
return wrapped;
}
}
Create custom exception handler
public class CustomExceptionHandler extends FullAjaxExceptionHandler{
static Logger log = Logger
.getLogger(CustomExceptionHandler.class);
public CustomExceptionHandler(ExceptionHandler wrapped) {
super(wrapped);
}
@Override
public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator();
if(unhandledExceptionQueuedEvents.hasNext()){
Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException();
log.error("FL Error",exception);
}
super.handle();
}
}