我正在尝试使用PrimeFaces 3.5的Spring 3.2.3项目来处理Tomcat 7.0.42,但我仍然坚持这个错误:
java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.
javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1135)
javax.faces.FactoryFinder.getFactory(FactoryFinder.java:379)
javax.faces.webapp.FacesServlet.init(FacesServlet.java:350)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
这是我的WebApplicationInitializer:
import javax.faces.webapp.FacesServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
public class Initializer implements WebApplicationInitializer {
private static final String JSF_SERVLET_NAME = "jsf";
private static final String JSF_SERVLET_MAPPING = "*.xhtml";
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootContext =
new AnnotationConfigWebApplicationContext();
rootContext.register(Config.class);
ServletRegistration.Dynamic jsf = servletContext.addServlet(
JSF_SERVLET_NAME, new FacesServlet());
jsf.addMapping(JSF_SERVLET_MAPPING);
servletContext.setInitParameter("javax.faces.STATE_SAVING_METHOD", "client");
servletContext.addListener(new ContextLoaderListener(rootContext));
}
}
我尝试在我的WebApplicationInitializer类上添加servletContext.addListener(new ConfigureListener());
行,但项目有时可以正常工作,有时却不行。
我使用的是jsf的2.2.1版本(jsf-api& jsf-impl)。