use of org.codice.ddf.platform.error.servlet.ErrorServlet in project ddf by codice.
the class ErrorPageInjector method createAndAddErrorPageHandler.
private void createAndAddErrorPageHandler(ServletContextHandler httpServiceContext, Bundle refBundle) {
// now that we have the handler, we can add in our own ErrorServlet
ServletHandler handler = httpServiceContext.getServletHandler();
ServletHolder errorServletHolder = new ServletHolder(new ErrorServlet());
errorServletHolder.setServletHandler(handler);
try {
errorServletHolder.start();
errorServletHolder.initialize();
} catch (Exception e) {
LOGGER.warn("Unable to initialize an errorServletHolder for {}. Jetty's default error page will be used for this context", refBundle.getSymbolicName(), e);
return;
}
LOGGER.info("Injecting an error page into {} ID: {}", refBundle.getSymbolicName(), refBundle.getBundleId());
handler.addServletWithMapping(errorServletHolder, ERROR_PAGE_PATH);
ErrorPageErrorHandler errorPageErrorHandler = new ErrorPageErrorHandler();
errorPageErrorHandler.setErrorPages(errorCodesMap);
errorPageErrorHandler.setShowStacks(false);
httpServiceContext.setErrorHandler(errorPageErrorHandler);
}
Aggregations