If I have an exception in my business layer (e.g. a SQL exception in my JDBC connection bean), how can I propagate it with a custom message to a global error.jsp
pa
I made an error page in the site faces and put the stacktrace of the error This code first put it in the web.xml
500
/errorpage.jsf
While the jsf page had this code
PLAN SEGURO
Error de ejecución
Ocurrio un error al realizar la operación, favor de intentarlo nuevamente, si el error aún se presenta, favor de notificarlo a soporte técnico al 5147-31-00 extensión 6893
Note that motif lets you debug the stacktrace for an reazon know which is the exception in the hidden field. Let's see how the class is defined recovers StackTrace
public class ErrorDisplay implements Serializable{
private static final long serialVersionUID = 6032693999191928654L;
public static Logger LOG=Logger.getLogger(ErrorDisplay.class);
public String getContacto() {
return "";
}
public String getStackTrace() {
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getRequestMap();
Throwable ex = (Throwable) requestMap.get("javax.servlet.error.exception");
StringWriter writer = new StringWriter();
PrintWriter pw = new PrintWriter(writer);
fillStackTrace(ex, pw);
LOG.fatal(writer.toString());
return writer.toString();
}
private void fillStackTrace(Throwable ex, PrintWriter pw) {
if (null == ex) {
return;
}
ex.printStackTrace(pw);
if (ex instanceof ServletException) {
Throwable cause = ((ServletException) ex).getRootCause();
if (null != cause) {
pw.println("Root Cause:");
fillStackTrace(cause, pw);
}
} else {
Throwable cause = ex.getCause();
if (null != cause) {
pw.println("Cause:");
fillStackTrace(cause, pw);
}
}
}
}
and already attached as you finish this bean definition in the file facesconfig
Bean que sirve para llenar la especificacion de un error. Stacktrace
errorDisplay
mx.com.tdc.datos.page.bean.ErrorDisplay
session
And I hope that this will serve