升级到JBoss 8后,RichFaces spacer gif URL出错(WildFly)

时间:2015-04-16 03:39:14

标签: jsf jboss richfaces wildfly-8

我正在从JBoss 6升级到JBoss 8(WildFly)。 RichFaces 3.3.3的版本保持不变。代码中的几个地方调用RichText spacer,如下所示:

<rich:spacer height="15" width="5"/>

web.xml中,与Faces相关的servlet-mapping条目如下所示:

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

运行JBoss 6时,间隔图像有以下URL,工作正常:

https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif

当我们升级到JBoss 8时,我们开始遇到问题。这个URL突然看起来像这样,并在访问时返回404 Not Found:

https://host.com/dc/faces/a4j/g/3_3_3.Finalimages/spacer.gif

我尝试从*.jsflike the documentation specifies删除servlet-mapping web.xml以外的所有内容。这使得URL看起来像这样:

https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf

访问时,URL返回500内部服务器错误:

ERROR [io.undertow.request] (default task-29) UT005023: Exception handling request to /dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf: javax.servlet.ServletException: org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : images/spacer.gif.jsf

图片始终可用原始网址。

供参考,这里是web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<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_3_0.xsd"
             version="3.0">

    <display-name>[clipped]</display-name>

    <context-param>
        <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
        <param-value>mojarra-1.2_15</param-value>
    </context-param>

    <context-param>
      <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
      <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>

    <context-param>
      <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
      <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>org.jboss.seam.core.init.debug</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <description>Disable MyFacesExtensionsFilter check</description>
        <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.LoadStyleStrategy</param-name>
        <param-value>NONE</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.LoadScriptStrategy</param-name>
        <param-value>NONE</param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.numberOfViewsInSession</param-name>
        <param-value>5</param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.numberOfLogicalViews</param-name>
        <param-value>5</param-value>
    </context-param>

    <servlet>
        <servlet-name>Seam Resource Servlet</servlet-name>
        <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Seam Resource Servlet</servlet-name>
        <url-pattern>/seam/resource/*</url-pattern>
    </servlet-mapping>

    <filter>
        <filter-name>Seam Filter</filter-name>
        <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
    </filter>

    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>Seam Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-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>*.jsf</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>45</session-timeout>
    </session-config>
</web-app>

我只是假设绕过这个问题并取消间隔,但是RichFaces也会在我们当前使用的一些组件内部调用spacer。

我该怎么做才能让间隔物正确显示?

1 个答案:

答案 0 :(得分:0)

您应该在web.xml的filter和filter-mapping部分中排除org.ajax4jsf.Filter的第二次初始化。 Seam从Ajax4jsfFilterInstantiator类中实例化org.ajax4jsf.Filter。

请从web.xml中删除以下代码

<filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
... 

<filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>

参见相关的RichFaces Issue RF-3410