{
FacesContext facesContext = FacesContext.getCurrentInstance();
URL url = SeamDebugPhaseListener.class.getClassLoader().getResource("META-INF/debug.xhtml");
Facelet f = new DefaultFaceletFactory( new SAXCompiler(), new DefaultResourceResolver() ).getFacelet(url);
UIViewRoot viewRoot = facesContext.getViewRoot();
f.apply(facesContext, viewRoot);
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; UTF-8");
ResponseWriter originalWriter = facesContext.getRenderKit().createResponseWriter( response.getWriter(), "text/html", "UTF-8" );
StateWriterControl.initialize(originalWriter);