Вопрос

I'm going through the excersise of upgrading our application from JEE5/Icefaces 1.8.2 to JEE6/Icefaces 3.3. I've followed material I've found here: Migrating from JSF 1.2 to JSF 2.0 as well as the Icefaces provided: http://www.icesoft.org/wiki/display/ICE/ICEfaces+1.x+Compatibility

So now I'm in a place where I can successfully deploy our application to GlassFish 3.

Here is the web.xml:

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>pdb</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
    <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
       <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>false</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <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-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>/icefaces/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>org.icefaces.ace.theme</param-name>
        <param-value>rime</param-value>
    </context-param> 
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>com.sun.faces.defaultResourceMaxAge</param-name>
        <param-value>604800</param-value>
    </context-param>
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/index.html</location>
    </error-page>
    <!-- ICE FACES ADDED -->

    <!-- Facelets Custom Components -->
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name> 
        <param-value>/WEB-INF/facelets/imsref_common_taglib.xml;/WEB-INF/facelets/imsref_pdb_taglib.xml</param-value> 
    </context-param>    

    <listener>
        <listener-class>LifeCycleListener</listener-class>
    </listener>
    <filter>
        <filter-name>RedirectFilter</filter-name>
        <filter-class>RedirectFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>RedirectFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>Transactions</filter-name>
        <filter-class>TransactionalFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>Transactions</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
    <!--Security Settings-->
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>pdb-auth-realm</realm-name>
        <form-login-config>
            <form-login-page>/login.jsf</form-login-page>
            <form-error-page>/loginerror.jsf</form-error-page>
        </form-login-config>
    </login-config>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>pdb</web-resource-name>
            <url-pattern>/secure/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>user</role-name>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    <!--Security constraint so only admin role can access the monitoring page-->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>monitoring</web-resource-name>
            <url-pattern>/monitoring</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>


    <security-role>
        <description>Administrator. Is the super-user. Can do everything. This role includes all other roles.</description>
        <role-name>admin</role-name>
    </security-role>
   <mime-mapping>
     <extension>aspx</extension>
     <mime-type>text/html</mime-type>
   </mime-mapping>
   <mime-mapping>
       <extension>png</extension>
       <mime-type>image/png</mime-type>
   </mime-mapping>
</web-app>

Now when I navigate to

https://localhost:8181/pdb/secure/main.jspx

I'm redirected to the login page but only the jsf components are being loaded. None of the .css is being loaded, when I navigate to the resources the response from the server is always Content-Length "0" but status 200. Same for any images.

When I authenticate against our realm, I can enter any URL after /pdb/ (i.e any garbage URL like)

https://localhost:8181/pdb/somenonexistantpage

and the server responds with 200 OK and Content-Length "0"

The structure of the application is as follows:

WEB-INF\login.xhtml
WEB-INF\index.xhtml
WEB-INF\loginerror.xhtml
WEB-INF\css\<custom css>
WEB-INF\resources\components\<components>
WEB-INF\resources\images\<images>
WEB-INF\resources\icons\<icons>
WEB-INF\secure\<all .xhtml jsf pages> 

The GET request:

https://localhost:8181/pdb/xmlhttp/css/rime/rime.css

returns only the following:

Content-Length:"0"
Date:"Tue, 19 Nov 2013 19:31:32 GMT"
Server:"GlassFish Server Open Source Edition 3.1.2.2"
X-Powered-By:"Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)"
Это было полезно?

Решение

To close the loop on this problem, my TransactionFilter was failing and we never chained the filter so the resource servlet was never getting hit. I ensured that the following line of code:

chain.doFilter(req, resp);

was getting executed and the resources were finally being loaded properly. I solved this a few weeks ago, but I believe that was the problem.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top