7 Replies Latest reply on Mar 27, 2015 4:26 PM by sublette131

    Files built by RichFaces resources plugin not found

    tarnschaf

      Hi,

       

      I am currently trying to modify an application based on the kitchensink example to use custom styling, mainly a custom font-family. I read about the different possibilities and decided the best way would be to create a new RichFaces skin.

       

      src/main/webapp/WEB-INF/Web.xml:

       <context-param>
        <param-name>org.richfaces.skin</param-name>
        <param-value>myskin</param-value>
       </context-param>
      

       

      src/main/resources/META-INF/skins/myskin.skin.properties:

      baseSkin=blueSky
      generalFamilyFont='Source Sans Pro', sans-serif
      generalSizeFont=15px
      

       

      Because using a custom skin in combination with resourceOptimization does not work out of the box, I followd Michal Petrov's blog entry about how to leverage the resource plugin to create own packed resource files (Thanks, a lot of information in it!). However, somehow the paths suggested in this tutorial do not match for our configuration and I haven't found a setting to change this until now.

       

      In detail:

      Maven builds the resources, creates the mapping file and places all in the .WAR directory/file. So far, so good. Further, the browser seems to load the packed.css from a correct URL, only JBoss then tries to load them from another resource folder and fails.

      The files are placed in \WEB-INF\classes\META-INF\resources\... (like suggested by the blog) and JBoss only looks in \resources\... and aborts.

       

      • Is this the "correct" placement for such resouces in a WAR file? Or should they somehow be placed in \resources?
      • Or, can/Should I somehow tell the "resource loader" to use a different base path for those resources?

       

      RichFaces version: 4.2.3.Final (like in the tutorial)

       

      Thanks for the help, the skinning feature is really nice but it seems to be hard to configure in our case...

        • 1. Re: Files built by RichFaces resources plugin not found
          michpetrov

          Hi,

           

          I don't quite understand what's happening

          … only JBoss then tries to load them from another resource folder and fails.

          you mean the server throws an exception? Can you show me the stacktrace?

           

          It is possible to put the resource in the /resources folder but I haven't found yet out how to make the browser look for them there.

          • 2. Re: Files built by RichFaces resources plugin not found
            tarnschaf

            Hi,

             

            thanks for the response.

             

            No, the server doesn't throw an exception. The browser simply receives a 404 response for packed.css - I used FileMonitor to see that JBoss looks for these files at the "wrong" place (only in \resources). However, following your tutorial, the files are placed in \WEB-INF\classes\META-INF\resources\. If I copy/move the generated folder to the first location manually, it works as expected.

             

            Btw I found a question on StackOverflow and maybe the OP has the same problem.

            • 3. Re: Files built by RichFaces resources plugin not found
              michpetrov

              Hm, okay. Can you show me your web.xml and the contents of the <head> element in the file you get from the server?

              • 4. Re: Files built by RichFaces resources plugin not found
                tarnschaf

                HTML Output inside <head>:

                 

                <script type="text/javascript" src="/ProjectName/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.2.3.Final/Packed/packed/packed.js"></script>
                <link type="text/css" rel="stylesheet" href="/ProjectName/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.2.3.Final/Packed/myskin/packed/packed.css" />
                

                 

                Probably relevant parts of Web.xml:

                 

                 

                <context-param>
                  <param-name>org.richfaces.enableControlSkinning</param-name>
                  <param-value>false</param-value>
                 </context-param>
                 <context-param>
                  <param-name>org.richfaces.resourceOptimization.enabled</param-name>
                  <param-value>true</param-value>
                 </context-param>
                 <context-param>
                  <param-name>org.richfaces.skin</param-name>
                  <param-value>myskin</param-value>
                 </context-param>
                


                • 5. Re: Files built by RichFaces resources plugin not found
                  michpetrov

                  You need to enable control skinning.

                   

                  You have an incomplete skin (because it relies on blueSky) and when you disable control skinning the server cannot find the base values. When you make a full skin you can disable it again.

                   

                  I am not sure why it behaves this way (i.e. not seeing the files even though they are where they are supposed to be. I'll look into it further and update the blog post.)

                  • 6. Re: Re: Files built by RichFaces resources plugin not found
                    sublette131

                    I'm seeing similar sounding issues with a custom skin, also based on BlueSky. I'm running on Tomcat, and I've updated to richfaces 4.5.0.Final. The solution I found elsewhere was to change resourceOptimization to false as shown below.

                     

                    That got me most of the way there. However, I'm seeing a similar issue on the initial page load that you see when org.richfaces.enableControlSkinning was false (mine was true/not present). Some components get the skin, others like buttons don't. It's only after I use the browser's refresh, the complete styles loaded. I've traced it down to the ECSS file not loading the first time, but I'm not sure why or how to ensure it gets loaded. This happens to me when resourceOptimization is disabled regardless of whether I use blueSky or my custom skin.

                     

                         <context-param>
                           <param-name>org.richfaces.resourceOptimization.enabled</param-name>
                           <param-value>false</param-value>
                         </context-param>
                         <context-param>
                           <param-name>org.richfaces.skin</param-name>
                           <param-value>myskin</param-value>
                           <!-- <param-value>blueSky</param-value> -->
                         </context-param>
                    
                    

                     

                    First load (no skinning.ecss file loaded):

                    http://localhost:8080/MyApp/faces/javax.faces.resource/theme.css?ln=css

                     

                    Second and subsequent loads:

                    http://localhost:8080/MyApp/org.richfaces.resources/javax.faces.resource/org.richfaces/skinning.ecss?

                    http://localhost:8080/MyApp/faces/javax.faces.resource/theme.css?ln=css

                    • 7. Re: Files built by RichFaces resources plugin not found
                      sublette131

                      My problem is probably slightly unrelated. I tracked my problem down to some sort of incompatibilities with prettyfaces (URL rewriting). Removing that library causes everything to load correctly the first time as well as subsequent times. Since I don't want to give up the URL rewriting functionality we have, I found a workaround - add the missing stylesheet manually in each web page:

                       

                          <h:head>

                          <link type="text/css" rel="stylesheet" href="#{request.contextPath}/org.richfaces.resources/javax.faces.resource/org.richfaces/skinning.ecss"/>

                          </h:head>...

                       

                      The drawback is that after that first load, any subsequent load will request two versions of skinning.ecss, the one above and the one that richfaces normally requests (.../skinning.ecss?db=.....). Since this shouldn't be modified on the server, it should be cached by most browsers.