java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory

。_饼干妹妹 提交于 2019-12-06 13:49:40
Ted Spradley

I resolved this by removing the parameter from the web.xml file.

 <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>

Removing the above text, rebuilding, exporting the war from Eclipse and deploying with the Tomcat Web Application Manager UI resolved the problem. Apparently, one of the jsf jars has this code built-in since http://java.sun.com/xml/ns/javaee/web-app_3_0 . I don't know this to be a fact, but read it in could not find Factory: javax.faces.context.FacesContextFactory. The difference here being that I removed the parameter instead of adding it.

I resolved this issue by removing the web.xml file and put these two methods in the Spring configuration file.

@Bean
public ServletContextInitializer servletContextCustomizer() {
        return new ServletContextInitializer() {
            @Override
            public void onStartup(ServletContext sc) throws ServletException {
sc.setInitParameter(Constants.ContextParams.THEME, "bootstrap");
sc.setInitParameter(Constants.ContextParams.FONT_AWESOME, "true");
sc.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME,ProjectStage.Development.name());
sc.setInitParameter("com.sun.faces.forceLoadConfiguration", "true");
sc.setInitParameter("contextConfigLocation", "test");
    }
  };
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
    FacesServlet servlet = new FacesServlet();
    ServletRegistrationBean registration = new ServletRegistrationBean(servlet, "*.jsf");
    registration.setName("Faces Servlet");
    registration.addUrlMappings("*.jsf");
    registration.setMultipartConfig(new MultipartConfigElement((String) null));
    registration.setEnabled(true);
    registration.setLoadOnStartup(1);
    return registration;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!