Jsf MyFaces 1.2的应用程序错误:java.lang.IllegalStateException:没有为此应用程序配置工厂

Jsf MyFaces 1.2的应用程序错误:java.lang.IllegalStateException:没有为此应用程序配置工厂,jsf,tomcat,myfaces,Jsf,Tomcat,Myfaces,对于我的应用程序,我使用的是Tomcat 6.0.x和Mojarra 1.2_04JSF实现。 它工作正常,只是我现在想切换到JSF的MyFaces 1.2_10impl 在部署my app a期间,出现以下错误: ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myApp]] StandardWrapper.Throwable java.lang.IllegalStateException: No F

对于我的应用程序,我使用的是Tomcat 6.0.xMojarra 1.2_04JSF实现。 它工作正常,只是我现在想切换到JSF的MyFaces 1.2_10impl

在部署my app a期间,出现以下错误:

ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myApp]] StandardWrapper.Throwable
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:106)
    at javax.faces.webapp.FacesServlet.init(FacesServlet.java:137)
    at org.apache.myfaces.webapp.MyFacesServlet.init(MyFacesServlet.java:113)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
...
编辑2

根据BalusC的建议,我对web.xml进行了一些编辑,以下是最终版本:

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Faces Servlet Delegator</servlet-name>
    <servlet-class>com.myapp.web.FacesServletDelegator</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet Delegator</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

Facesservlet
javax.faces.webapp.FacesServlet
1.
面向Servlet委托人
com.myapp.web.FacesServletDelegator
2.
面向Servlet委托人
*.jsf

在我的例子中,从my web.xml中删除以下行:

<load-on-startup>1</load-on-startup>
1
…是什么让错误消失了


(正在安装一个纯Tomcat7来与JSF一起工作。)

我不做MyFaces,但事实上我很惊讶,你显然需要对javax.faces.webapp.FacesServlet指定的JSF2.0API进行注释,并使用MyFaces特定的API。这意味着MyFaces与JSF2.0API不兼容。或者这只是你的无知?撤消该outcomment并删除MyFaces impl特定的声明,然后重试。它能用吗?它能用。谢谢你指出这一点。当我在寻找最初问题的原因时,我可能也做了这个改变。我将根据您的建议编辑我的问题…只是为了回答前面的评论并澄清一下,MyFaces Core与JSF2.0API是100%兼容的,因为在每次发布之前进行的一些测试都会检查这一点。覆盖默认的标准FacesServlet并使用委托—一个是特定于实现的,这意味着它是“超出”规范的黑客行为。有一些有效的用例可以做到这一点,但作为“最佳实践”,您不应该依赖于此。如果你有更多关于MyFaces的问题,你可以在
public class PLMFacesServlet extends HttpServlet implements DelegatedFacesServlet {

    private MyFacesServlet delegate;

    public final void init(ServletConfig servletConfig) throws ServletException {
        delegate = new MyFacesServlet();
        delegate.init(servletConfig);
    }

    public final void destroy() {
        delegate.destroy();
    }

    public final ServletConfig getServletConfig() {
        return delegate.getServletConfig();
    }

    public final String getServletInfo() {
        return delegate.getServletInfo();
    }

    public final void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {

       try {
           delegate.service(request, response);
       } catch(Exception e) {}
    }
    // some other code...
}
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Faces Servlet Delegator</servlet-name>
    <servlet-class>com.myapp.web.FacesServletDelegator</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet Delegator</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<load-on-startup>1</load-on-startup>