JSF: javax.faces.resources is not referenced in my

2019-08-27 03:35发布

问题:

Resources folder containing js and css file from javax.faces.resource is not referenced in my application, here is the front end errorlog that i get using Chrome developer tools

GET http://demo:2008/javax.faces.resource/themes/sam/theme.css.jsp?ln=icefaces.ace 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/util/ace-components.js.jsp?ln=icefaces.ace 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/yui/yui-min.js.jsp?ln=yui/3_1_1&v=3068887 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/util/combined.css.jsp?ln=icefaces.ace 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/loader/loader-min.js.jsp?ln=yui/3_1_1&v=3068887 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/util/ace-jquery.js.jsp?ln=icefaces.ace 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/yui2-skin-sam-button/assets/button-core.css.jsp?ln=yui/2in3 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/combined.js.jsp?ln=org.icefaces.component.util&v=3068887 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/yui2-skin-sam-tabview/assets/tabview-core.css.jsp?ln=yui/2in3 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/combined.css.jsp?ln=org.icefaces.component.util 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/fileEntry.js.jsp?ln=org.icefaces.component.fileentry&v=3068887 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/slider/assets/slider-core.css.jsp?ln=yui/3_1_1 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/bridge.js.jsp?v=3068887 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/icefaces-compat.js.jsp 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/compat.js.jsp 404 (Not Found)
JobImport.jsp:246GET http://demo:2008/javax.faces.resource/jsf.js.jsp?ln=javax.faces&v=3068887 404 (Not Found)
JobImport.jsp:249Uncaught ReferenceError: ice is not defined
(anonymous function)JobImport.jsp:249
JobImport.jsp:250Uncaught ReferenceError: ice is not defined
(anonymous function)JobImport.jsp:250
JobImport.jsp:253Uncaught ReferenceError: ice is not defined
JobImport.jsp:254Uncaught ReferenceError: ice is not defined

Is there any particular configuration that we need to do so that javax.faces.resources are properly referenced in our application?

Updates : Added jsp, xhtml and web.xml files

Here is my jsp page

    <html>
<head>
    <!-- BEGIN SCRIPT TO OPEN RIGHT NOW HELP POPUP, THIS SCRIPT INCLUDES THE FUNCTION OPENRN-->
    <%@ include file="/js/popupRightNow.inc" %>

    <!-- END SCRIPT TO OPEN RIGHT NOW HELP POPUP, THIS SCRIPT INCLUDES THE FUNCTION OPENRN-->
    <title>Test</title>

    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<jsp:include page="/navigation/TopNav.jsp" flush="true"/>

<jsp:include page="/entry/Upload.xhtml"/>


<!--BEGIN BOTTOM NAV -->
<jsp:include page="/navigation/BottomNav.jsp" flush="true"/>
<!--END BOTTOM NAV -->
</body>
</html>

Here is my xhtml page:

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

<h:head>
    <title>ICEfaces 3</title>
    <!-- <link rel="stylesheet" type="text/css" href="/xmlhttp/css/rime/rime.css"/> -->
</h:head>
<h:body>
         <h:form id="form">
            <h:outputText value="Welcome to ICEfaces 3, select current date: "/>
            <ace:dateTimeEntry renderAsPopup="true">
                <f:convertDateTime pattern="MM/dd/yyyy" timeZone="Canada/Mountain"/>
            </ace:dateTimeEntry>
            <ace:fileEntry id = "fileUpload"
                           label="File Entry"
                           relativePath="uploaded"
                           fileEntryListener="#{fileUpload.uploadFile}"/>
         <h:commandButton value="Upload File" />
         </h:form>
</h:body>

Here is my web.xml

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

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app >
 <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>

<context-param>
<param-name>com.icesoft.faces.concurrentDOMViews</param-name>
<param-value>false</param-value>
</context-param>

<context-param>
<param-name>com.icesoft.faces.synchronousUpdate</param-name>
<param-value>false</param-value>
</context-param>

<context-param>
<param-name>com.icesoft.faces.blockingRequestHandler</param-name>
<param-value>icefaces</param-value>
</context-param>

<context-param>
<param-name>com.icesoft.faces.checkJavaScript</param-name>
<param-value>false</param-value>
</context-param>

  <!-- filters.xml : Non-XDoclet filter declarations, merged into web.xml by XDoclet. -->



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

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


</web-app>

回答1:

You've got some mess with your URLs and servlet mappings. You have requested your JSF page with suffix .jsp. As a consequence all resource requests reuse this prefix:

GET http://demo:2008/javax.faces.resource/util/ace-components.js.jsp?ln=icefaces.ace

My guess is you have somehow mapped the original request to the faces servlet but the subsequent resource requests fail to match the mapping pattern.

I recommend two things: don't use .jsp as an extension for JSF page requests. Make it .jsf or something else unused. Then make sure you've got proper servlet mapping, mapping this extension to the faces servlet:

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