FacesServlet tidak berfungsi di fragmen web

Saya memiliki dua aplikasi web (web-module1.war & web-module2.war) dan saya ingin menggunakan fragmen web (web-core.jar) untuk deklarasi servlet umum seperti FacesServlet.

Ketika saya mendeklarasikan FacesServlet di web.xml tidak ada masalah, tetapi ketika saya memindahkan deklarasi ini ke web-fragment.xml saya mendapatkan kesalahan ini:

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>

Saya tidak punya masalah dengan deklarasi servlet/filter lainnya!

Web-fragment.xml ada di folder META-INF web-core.jar dan juga Faces-config.xml.

Web-core.jar dinyatakan sebagai ketergantungan maven (saya dapat menemukannya di WEB-INF/lib).

Ini adalah web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" metadata-complete="false"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment metadata-complete="true" version="3.0"
    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-fragment_3_0.xsd">

    <name>core_web_fragment</name>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-*.xml</param-value>
    </context-param>
    <!-- /Spring Config -->
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>inscription.xhtml</welcome-file>
    </welcome-file-list>
</web-fragment>
0.xsd" 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
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment metadata-complete="true" version="3.0"
    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-fragment_3_0.xsd">

    <name>core_web_fragment</name>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-*.xml</param-value>
    </context-param>
    <!-- /Spring Config -->
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>inscription.xhtml</welcome-file>
    </welcome-file-list>
</web-fragment>
0.xsd"> <absolute-ordering> <name>core_web_fragment</name> </absolute-ordering> </web-app>

Dan web-fragment.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-fragment metadata-complete="true" version="3.0"
    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-fragment_3_0.xsd">

    <name>core_web_fragment</name>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-*.xml</param-value>
    </context-param>
    <!-- /Spring Config -->
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>inscription.xhtml</welcome-file>
    </welcome-file-list>
</web-fragment>

Saya menggunakan Tomcat7


person Mohamed Ramrami    schedule 26.03.2015    source sumber


Jawaban (1)


Jika Anda menggunakan implementasi Apache Myfaces JSF, ini adalah bug yang diketahui

Jadi Anda harus mengubahnya (gunakan MOJARRA misalnya)

person reda la    schedule 26.03.2015