我正在尝试使用 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));
}
}
我试图servletContext.addListener(new ConfigureListener());
在我的 WebApplicationInitializer 类上添加一行,但是该项目有时有效,有时无效。
我正在使用 2.2.1 版本的 jsf(jsf-api 和 jsf-impl)。