/** * Return the detail message, including the message from the nested exception * if there is one. */ @Override @Nullable public String getMessage() { return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); }
/** * Return the detail message, including the message from the nested exception * if there is one. */ @Override @Nullable public String getMessage() { return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); }
@Override public void doFilterInternal(HttpServletRequest baseRequest, HttpServletResponse baseResponse, FilterChain chain) throws IOException, ServletException { try { super.doFilterInternal(baseRequest, baseResponse, chain); } catch (ServletException e) { if (e.getCause() instanceof StaleStateServiceException) { LOG.debug("Stale state detected", e); baseResponse.setStatus(HttpServletResponse.SC_CONFLICT); baseResponse.getWriter().write("Stale State Detected\n"); baseResponse.getWriter().write(e.getMessage() + "\n"); } else if (e.getCause() instanceof ServiceException) { //if authentication is null and CSRF token is invalid, must be session time out if (SecurityContextHolder.getContext().getAuthentication() == null && failureHandler != null) { baseRequest.setAttribute("sessionTimeout", true); failureHandler.onAuthenticationFailure(baseRequest, baseResponse, new SessionAuthenticationException("Session Time Out")); } else { throw e; } } else { throw e; } } } }
ret.put("error", e.getMessage()); } catch (final ScheduleManagerException e) { logger.error(e.getMessage(), e);
pageContext.handlePageException(e); } catch (ServletException e2) { throw new JspException(e2.getMessage()); } catch (IOException e2) { throw new JspException(e2.getMessage());
@Test public void notAuthorized() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do"); request.addPreferredLocale(Locale.CANADA); MockHttpServletResponse response = new MockHttpServletResponse(); try { complexDispatcherServlet.service(request, response); assertTrue("Correct response", response.getStatus() == HttpServletResponse.SC_FORBIDDEN); } catch (ServletException ex) { fail("Should not have thrown ServletException: " + ex.getMessage()); } }
@Test public void modelAndViewDefiningException() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do"); request.addPreferredLocale(Locale.CANADA); request.addUserRole("role1"); request.addParameter("fail", "yes"); MockHttpServletResponse response = new MockHttpServletResponse(); try { complexDispatcherServlet.service(request, response); assertEquals(200, response.getStatus()); assertTrue("forwarded to failed", "failed1.jsp".equals(response.getForwardedUrl())); } catch (ServletException ex) { fail("Should not have thrown ServletException: " + ex.getMessage()); } }
@Test public void notDetectAllViewResolvers() throws ServletException, IOException { DispatcherServlet complexDispatcherServlet = new DispatcherServlet(); complexDispatcherServlet.setContextClass(ComplexWebApplicationContext.class); complexDispatcherServlet.setNamespace("test"); complexDispatcherServlet.setDetectAllViewResolvers(false); complexDispatcherServlet.init(new MockServletConfig(getServletContext(), "complex")); MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/unknown.do"); MockHttpServletResponse response = new MockHttpServletResponse(); try { complexDispatcherServlet.service(request, response); fail("Should have thrown ServletException"); } catch (ServletException ex) { // expected assertTrue(ex.getMessage().contains("failed0")); } }
@Test public void notDetectAllHandlerExceptionResolvers() throws ServletException, IOException { DispatcherServlet complexDispatcherServlet = new DispatcherServlet(); complexDispatcherServlet.setContextClass(ComplexWebApplicationContext.class); complexDispatcherServlet.setNamespace("test"); complexDispatcherServlet.setDetectAllHandlerExceptionResolvers(false); complexDispatcherServlet.init(new MockServletConfig(getServletContext(), "complex")); MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/unknown.do"); MockHttpServletResponse response = new MockHttpServletResponse(); try { complexDispatcherServlet.service(request, response); fail("Should have thrown ServletException"); } catch (ServletException ex) { // expected assertTrue(ex.getMessage().contains("No adapter for handler")); } }
@Test public void themeChangeInterceptor2() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do"); request.addPreferredLocale(Locale.CANADA); request.addUserRole("role1"); request.addParameter("theme", "mytheme"); request.addParameter("theme2", "theme"); MockHttpServletResponse response = new MockHttpServletResponse(); try { complexDispatcherServlet.service(request, response); assertTrue("Not forwarded", response.getForwardedUrl() == null); } catch (ServletException ex) { fail("Should not have thrown ServletException: " + ex.getMessage()); } }
public void setServletConfig(ServletConfig servletConfig) { try { shadowCxfServlet = (Servlet)servletClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } try { shadowCxfServlet.init(servletConfig); } catch (ServletException ex) { throw new RuntimeException(ex.getMessage(), ex); } }
assertEquals("test", ex.getMessage());
serviceListGenerator.init(servletConfig); } catch (ServletException e) { throw new RuntimeException(e.getMessage(), e);
@Test public void testFilterMultiple() { final GenericFilterImpl filter = new GenericFilterImpl(); try { filter.init(makeFilterConfig()); } catch (ServletException e) { fail(e.getMessage()); } FilterChain chain = new MyFilterChain(new Filter[] { filter, filter, filter, filter, filter }); try { chain.doFilter(makeRequest(), makeResponse()); } catch (IOException e) { fail(e.getMessage()); } catch (ServletException e) { fail(e.getMessage()); } assertEquals("Filter was invoked not invoked five times!", 5, filter.invocationCount); filter.destroy(); }
@Test public void testInit() { Filter filter = makeFilter(); try { filter.init(makeFilterConfig()); } catch (ServletException e) { assertNotNull(e.getMessage()); } finally { filter.destroy(); } }
@Test public void testFilterOnlyOnce() { final GenericFilterImpl filter = new GenericFilterImpl(); filter.setOncePerRequest(true); try { filter.init(makeFilterConfig()); } catch (ServletException e) { fail(e.getMessage()); } FilterChain chain = new MyFilterChain(new Filter[] {filter, filter, filter}); try { chain.doFilter(makeRequest(), makeResponse()); } catch (IOException e) { fail(e.getMessage()); } catch (ServletException e) { fail(e.getMessage()); } assertEquals("Filter was invoked more than once!", 1, filter.invocationCount); filter.destroy(); }
fail(e.getMessage()); fail(e.getMessage()); fail(e.getMessage());
public void setServletConfig(ServletConfig servletConfig) { try { shadowCxfServlet = (Servlet)servletClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } try { shadowCxfServlet.init(servletConfig); } catch (ServletException ex) { throw new RuntimeException(ex.getMessage(), ex); } }
public FilterChainManager stormpathFilterChainManager() { DefaultFilterChainManager mgr = new DefaultFilterChainManager(servletContext); try { addRoutes(mgr); return mgr; } catch (ServletException e) { String msg = "Could not create Filter Chain Manager: " + e.getMessage(); throw new BeanCreationException(msg, e); } }
protected void deployServlet(final DeploymentInfo deploymentInfo) { DeploymentManager manager = ServletContainer.Factory.newInstance().addDeployment(deploymentInfo); manager.deploy(); deployment = manager.getDeployment(); try { injectedHost.getValue().registerDeployment(deployment, manager.start()); } catch (ServletException e) { RTSLogger.ROOT_LOGGER.warn(e.getMessage(), e); deployment = null; } }