6 Replies Latest reply on Sep 17, 2014 1:14 PM by M S

    Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load

    M S Newbie

      My web application, running on Tomcat 7, is using JSF 2.1.29 and RF 4.5.0.Beta2 and runs fine.  If I switch my JSF dependency in my Maven project to 2.2.8 (the latest JSF version), then I start seeing serious issues with my application when it runs.  Specifically, whenever the page tries to render CSS or JavaScript links in the header, I see things like the following:

      <script src="/mywebapp/org.richfaces.resources/javax.faces.resource/RESOURCE_NOT_FOUND" type="text/javascript"></script>

      <link href="/mywebapp/org.richfaces.resources/javax.faces.resource/RESOURCE_NOT_FOUND" rel="stylesheet" type="text/css">

       

      I do not see any exceptions in any of the Tomcat logs.

       

      My 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"

               version="3.0">

      ...

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

      mapping>

      <servlet>
         <servlet-name>Resource Servlet</servlet-name>
         <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
         <servlet-name>Resource Servlet</servlet-name>
         <url-pattern>/org.richfaces.resources/*</url-pattern>
      </servlet-mapping>

       

      I don't know if the resources servlet is still required -- none of the documentation references it.  Commenting it out does not do anything.

       

      I am still debugging this, but additional hints as to where to look would be appreciated.

       

      Edit: OK, so what I think I have found is that RF4.x does not support JSF 2.2, so I might be trying something really dumb.  There is no conclusive documentation on this matter, however.

        • 1. Re: Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load
          Michal Petrov Master

          Hi,

           

          can you try running it with Mojarra 2.2.6? That one is supported so if it still doesn't work the issue might be in your app. The resource servlet registers itself automatically, so you don't need to have it in web.xml.

          • 2. Re: Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load
            M S Newbie

            Using 2.2.6 does not seem to have resolved anything.

             

            I do have a servlet filter and a few other things hooked into JSF (phase listeners and so on), so I have to debug those I imagine.  It is really bizarre to me, though, to see CSS and JavaScript file names be rendered as "RESOURCE_NOT_FOUND" when I would have thought that these things would be hardcoded or something.  I will have to download the source for all of these things as well, but at least IntelliJ makes that easy.

             

            Edit: Temporarily commented out my filter and faces components, but the problem still happens.  I have to investigate the rest of my configuration at this point.

            • 3. Re: Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load
              M S Newbie

              Yeah, I removed all of the phase listeners, session listeners, configuration parameters (like the skin and everything) and I am trying to run it with as minimal of a set of configuration as possible and I still get the RESOURCE_NOT_FOUND in the references to the CSS and JavaScript files.  I might just try to stand up a completely new/plain web application with the bare necessities to see if the problem happens there.  I also was unable to track down who would be rendering the <head> tag where the links to CSS/JS files are.  I found the resource files that contain some of the paths, but I could not track it down any further.

               

              Edit: All right, so richfaces-core-4.5.0.Beta2-sources.jar!\org\richfaces\resource\mapping\ResourceServletMapping.java line 84 is where the string literal lives.  context.getApplication().getResourceHandler().createResource(resourceKey.getResourceName(), resourceKey.getLibraryName()) return null.  Will be diving into that call to figure out why it is doing this.  To be clear, getResourceName() and getLibraryName() both return what look like valid values. 

              • 4. Re: Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load
                M S Newbie

                I traced the code down as much as I possibly could.  RF4.5 is using the JSF resources stuff, but it seems like JSF is not returning any resources at all used by RF.  I'm not sure which side is at fault, but the full library name and resource name is provided.  I saw it go through several different loaders to try and find the resource.  I think at this point I have to revert back to JSF 2.1 and deal with the consequences of that. 

                • 5. Re: Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load
                  Pavol Pitonak Master

                  Hi, were you able to reproduce with a minimal application? It works fine for me with Mojarra 2.2.6. I have same web.xml configuration as you do.

                   

                  Pavol

                  • 6. Re: Upgrading from JSF 2.1.29 to 2.2.8 causes JavaScript and CSS files to not load
                    M S Newbie

                    I have not had a chance to do that yet.  I had to revert my project back to 2.1.29 for the time being.  I might not have time to try that for a little bit, but I hope I can.