Bom tarde,
como passar um parâmetro contendo a “stacktrace” da mensagem de erro, de uma classe que extende “ExceptionHandlerWrapper”, para uma página xhtml.
Por exemplo:
public class JsfExceptionHandler extends ExceptionHandlerWrapper {
@Override
public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();
while (events.hasNext()) {
ExceptionQueuedEvent event = events.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable exception = context.getException();
NegocioException negocioException = getNegocioException(exception);
boolean handled = false;
try {
if (exception instanceof ViewExpiredException) {
handled = true;
redirect("/");
} else if (negocioException != null) {
handled = true;
FacesUtil.addErrorMessage(negocioException.getMessage());
} else {
handled = true;
log.error("Erro de sistema: " + exception.getMessage(), exception);
redirect("/Erro.xhtml");
}
} finally {
if (handled) {
events.remove();
}
}
}
getWrapped().handle();
}
Neste exemplo quero passar a stacktrace como String para ser exibida na página Erro.xhtml. Como posso fazer?
O problema é que quando tento usar @Inject ou @ManagedProperty para injetar qualquer bean gerenciado, estou recebendo NPE ou o atributo String que deveria receber a mensagem da stacktrace chega com NULL.
Alguém pode ajudar?