找不到Factory:javax.faces.application.ApplicationFactory

时间:2011-10-31 17:09:39

标签: java-ee jsf-2 icefaces

您好我正在尝试一起使用以下技术:

  • JSF 2.1.0
  • ICEFaces 2.0.2 这是根据他们的文档,适用于 JSF 2.1.x
  • Tomcat 6

我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      version="2.5"> 

  <display-name>appName</display-name>

  <listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

  <listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
  </listener>

  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        classpath:META-INF/spring/applicationContext.xml
        </param-value>

  </context-param>


  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

  <welcome-file-list>
    <welcome-file>/</welcome-file>
  </welcome-file-list>



  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>

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

  <context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
  </context-param>


  <servlet>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/xmlhttp/*</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>

</web-app>

但是在尝试运行我的应用程序时,我得到以下异常:

SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:815)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:317)
    at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:112)
    at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:329)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4245)
    at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4886)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4750)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

任何想法为什么?

2 个答案:

答案 0 :(得分:8)

JSF 2.1 requires与Servlet 3.0兼容的容器,但Tomcat 6只是一个Servlet 2.5 compatible容器。你有两个选择:

  1. 将JSF 2.1降级为JSF 2.0(Mojarra 2.0为currently,版本为2.0.6)。
  2. 将Tomcat 6.0升级到Tomcat 7.0(并更改web.xml根声明符合Servlet 3.0。)
  3. 如果您选择选项2(升级到Tomcat 7.0),那么您应该将Mojarra 2.1.0升级到至少 Mojarra 2.1.1(它已经是currently已经在2.1.3) 。这是必需的,因为Mojarra 2.1.0包含注释扫描程序中的错误,这使得它与Tomcat和Jetty不兼容。

    另见:

答案 1 :(得分:-1)

我使用两种方法解决了这个问题:

1.删除了两个不同版本的jsf(例如jsf 1.x或jsf2.x)或者从项目中移除了两个不同的jsf实现(mojarra jsf或myfaces)。我只使用了一个实现mojarra(或myfaces) )但不是两个。我在jsf不同版本的罐子(即使用jsf 2.x罐子)而不是jsf 1.x的情况下做了同样的事情。

2.从接口中删除@ManagedBean注释。