Buggy code:
public class WicketFilter implements Filter { private static final Logger log = LoggerFactory . getLogger ( WicketFilter . class ) ; public static final String FILTER_MAPPING_PARAM = "filterMappingUrlPattern" ; public static final String APP_FACT_PARAM = "applicationFactoryClassName" ; private WebApplication application ; private FilterConfig filterConfig ; private String filterPath ; private int filterPathLength = - 1 ; protected ClassLoader getClassLoader ( ) { } boolean processRequest ( final ServletRequest request , final ServletResponse response , final FilterChain chain ) throws IOException , ServletException { boolean res = true ; final ClassLoader previousClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; final ClassLoader newClassLoader = getClassLoader ( ) ; try { if ( previousClassLoader != newClassLoader ) { Thread . currentThread ( ) . setContextClassLoader ( newClassLoader ) ; } HttpServletRequest httpServletRequest = ( ( HttpServletRequest ) ( request ) ) ; HttpServletResponse httpServletResponse = ( ( HttpServletResponse ) ( response ) ) ; String filterPath = getFilterPath ( httpServletRequest ) ; String redirectURL = checkIfRedirectRequired ( httpServletRequest ) ; if ( redirectURL == null ) { application . set ( ) ; WebRequest webRequest = application . newWebRequest ( httpServletRequest , filterPath ) ; <START_BUG> WebResponse webResponse = application . newWebResponse ( httpServletRequest , httpServletResponse ) ; <END_BUG> RequestCycle requestCycle = application . createRequestCycle ( webRequest , webResponse ) ; if ( ! ( requestCycle . processRequestAndDetach ( ) ) ) { if ( chain != null ) { chain . doFilter ( request , response ) ; } res = false ; } else { webResponse . flush ( ) ; } } else { if ( ( Strings . isEmpty ( httpServletRequest . getQueryString ( ) ) ) == false ) { redirectURL += "?" + ( httpServletRequest . getQueryString ( ) ) ; } try { httpServletResponse . sendRedirect ( httpServletResponse . encodeRedirectURL ( redirectURL ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } finally { ThreadContext . detach ( ) ; if ( newClassLoader != previousClassLoader ) { Thread . currentThread ( ) . setContextClassLoader ( previousClassLoader ) ; } response . flushBuffer ( ) ; } return res ; } public void doFilter ( final ServletRequest request , final ServletResponse response , final FilterChain chain ) throws IOException , ServletException { } protected IWebApplicationFactory getApplicationFactory ( ) { } public final void init ( final FilterConfig filterConfig ) throws ServletException { } public void init ( final boolean isServlet , final FilterConfig filterConfig ) throws ServletException { } public FilterConfig getFilterConfig ( ) { } protected String getFilterPath ( final HttpServletRequest request ) { } public void destroy ( ) { } private String checkIfRedirectRequired ( final HttpServletRequest request ) { } protected final String checkIfRedirectRequired ( final String requestURI , final String contextPath ) { } public final void setFilterPath ( final String filterPath ) { } }

Fix:
WebResponse webResponse = application . newWebResponse ( webRequest , httpServletResponse ) ;