14 Replies Latest reply on May 29, 2012 12:52 PM by Hakan Moral

    Richfaces styles not being applied (intermitent)

    Enrico Goosen Newbie

      I'm experiencing a strange problem with my Seam war app, in that the Richfaces stylesheet is not being applied.
      What's strange is that it was working, and then it stopped working, and then I got it working again somehow, and now its not working again.
      I'm completely baffled! I've spent hours trying various things, but I've run out of ideas.
      I had an ear app, and two war apps deployed to the server, and I thought that maybe somehow there was a conflict, so I undeployed the two other apps, and then I cleared the cache, and refreshed the page and BINGO it worked. Then I redeployed the ear app that I deleted previously, and restarted the server, and then my app stuffed up again.
      So I figured it must have something to do with the ear app. So I undeployed the ear app again, and restarted the server, cleared cache etc...but now my app still isn't working properly. So I don't know...

      Any ideas?

        • 1. Re: Richfaces styles not being applied (intermitent)
          Enrico Goosen Newbie

          I opened up firebug and noticed this:

          Failed to load source for: http://localhost:8080/mymedAdmin/a4j/s/330.GAstylesheet/theme.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ

          Any ideas why this is happening?

          • 2. Re: Richfaces styles not being applied (intermitent)
            Enrico Goosen Newbie

            I'm getting closer, but still haven't fixed the problem...

            My ear app seems to be loading its stylesheets fine. Here's an example path:


            I noticed that the version is different, so I tried replacing all the richfaces jar, but somehow my path still shows a different version:


            How do I get it to use version 322?

            • 3. Re: Richfaces styles not being applied (intermitent)
              Enrico Goosen Newbie

              Still no luck...:(

              The generated app works with same richfaces version.

              Firebug output:

              <link class="component" type="text/css" rel="stylesheet" href="/mymed_2_1_2/a4j/s/3_3_0.GA/org/richfaces/skin.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__">
              //css is properly outputed here...

              My semi-generated app fails:

              <link class="component" type="text/css" rel="stylesheet" href="/mymedAdmin/a4j/s/3_3_0.GA/org/richfaces/skin.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__">
                Failed to load source for: http://localhost:8080/mymedAdmin/a4j/s/3_3_0.GA/org/richfaces/skin.xcss/DATB/eAHbdnRLUujyGdIAFdEEQQ__

              I replaced the following jars in my app:





              Why does it load fine in the one app, and fails in the other?
              The difference between the two apps, is that the one is an ear and the other is a war.
              The war is not working properly.

              • 4. Re: Richfaces styles not being applied (intermitent)
                Enrico Goosen Newbie

                Wow! I found quite a few JIRA issues that seem similar to my problem:






                • 5. Re: Richfaces styles not being applied (intermitent)
                  Dave Oxley Newbie

                  Here's one that I raised that I still haven't gotten to the bottom of:

                  • 6. Re: Richfaces styles not being applied (intermitent)
                    Diego Silva Newbie

                    Hi Enrico.
                    I got the same problem, but I'm using only RichFaces over JSP (I'm sorry for that).
                    Did you get any solution for this issue????

                    • 7. Re: Richfaces styles not being applied (intermitent)
                      Enrico Goosen Newbie
                      Hi Diego,

                      The problem was caused by using a wildcard (*) to apply login required to all screens in my app. I changed it back to the normal configuration in pages.xml then the bug went away.
                      The drawback is that I had to specify login required per page.

                      • 8. Re: Richfaces styles not being applied (intermitent)
                        Richard Taylor Newbie
                        I've just spent the last few hours debugging this and figured out the issue.  We were hitting the same problem, but needed caching in production.  Posting my notes for others.

                        Explanation of problem:
                        - Initial request for a Seam page comes in from from an unauthenticated user.
                        - As a result of page view-id="*" login-required="true" in pages.xml, Seam returns 302 / redirect, sends browser to Page B
                        - Page B contains references to richfaces resources (xcss, etc.) (Due to our usage of org.richfaces.LoadStyleStrategy [All], etc.)
                        - Due to these resource references in Page B, browser makes request for these resources (i.e. org/richfaces/renderkit/html/css/extended_both.xcss/DATB/eAHziU!XD10-QxoADOoC8Q__, etc.)
                        - User is still NOT authenticated at this point
                        - Request for resources goes into A4J's InternetResourceService.serviceResource()-> LRUMapCache.load() -> InternetResourceService.load()
                        - InternetResourceService.load() processes the JSF request lifecycle to render the resource, but in Seam's Pages.postRestore(), Seam responds with a redirect because this resource ALSO matches  view-id="*" pattern and the user is still not yet authenticated
                        - This "response" from rendering the resource (really just a 302, contentLength of 0, garbage), is put into the LRUMapCache by A4J
                        - All subsequent requests for this resource (i.e. org/richfaces/renderkit/html/css/extended_both.xcss/DATB/eAHziU!XD10-QxoADOoC8Q__) return that garbage/cached value.
                        - Richfaces themes / resources / styles are gone until server is restarted

                        Fixes / Workarounds:
                        - Change richfaces code to recognize 503 / invalid responses and NOT cache them
                        - Disable a4j caching with <web:ajax4jsf-filter enable-cache="false".../>
                        - Change page view-id="*" login-required="true" so that it does not match a4j resource requests.  (our current solution)
                        - Make sure that no page hit by an unauthenticated user ever contains richfaces resources (at least until an authenticated user has the same pages first)
                        • 9. Re: Richfaces styles not being applied (intermitent)
                          Sean Jensen Newbie
                          Thank you for posting this.  I've been going crazy trying to figure this out.  Unfortunately I've been unable to implement your solutions.  I don't know how to go about recognizing the 503 error in richfaces and disabling the caching, I'm not sure where to implement the line to disable the cache, my pages.xml already has the page view-id set to '*' and login-required is true and I am having this problem from the moment I start the server and so can't log in an authenticated user to set this up. 
                          I can't believe this is the way it's supposed to be.  I've done nothing interesting so this seems like a horrible flaw.  Where did I go wrong and why isn't everyone having the same problem?
                          • 10. Re: Richfaces styles not being applied (intermitent)
                            Richard Taylor Newbie

                            Hello, it's been a while, but let me see what I can dig up.  Note that with the fixes / workarounds I mentioned in my last post, you only need to do _one_ of those.
                            - The first one I mentioned would be a code change to Richfaces, not optimal from a user perspective, you would want that to come from the Richfaces folks (unlikely at this point).
                            - To disable a4j caching, that can be done in components.xml, here is our entry:
                                 <web:ajax4jsf-filter force-parser="true"

                            - On the third workaround, in our pages.xml we made the following change.  It makes it so that a4j resource requests don't get caught up in seam security (for better or worse):
                                 <page view-id="*" login-required="true" />
                                 <page view-id="/logon/*" login-required="true" />
                                 <page view-id="/test/*" login-required="true" />
                                 <page view-id="/layout/*" login-required="true" />

                            - The last workaround isn't realistic but I wanted to point it out because it's how the problem starts.
                            • 11. Re: Richfaces styles not being applied (intermitent)
                              Sean Jensen Newbie

                              Thanks for your reply.  I'll disable caching for now.

                              I was a little worried about the last option so it's comforting to know I am not totally hopeless.  :)

                              • 12. Re: Richfaces styles not being applied (intermitent)
                                Martin Frey Newbie

                                i think i just solved this painfull issue with a very simple approach. Before i did the same as Richard mentioned and this worked well. I want to have the a4j cache etc. so i moved all pages with login into one folder ./s/*.


                                Now i just had the idea to create a wildcard viewid *.xhtml. Too bad that the the wildcard viewids need to end with a star.. But this seems to work well:

                                <page login-required="true" view-id="*.xhtml*" />

                                The only disadvantage is that all other files except xhtml are available without login, but this is something i can live with easily.

                                Can somebody please confirm this?

                                • 13. Re: Richfaces styles not being applied (intermitent)
                                  Martin Frey Newbie

                                  Forget my previous post. Pages implementation uses startsWith... for wildcard view ids

                                  • 14. Re: Richfaces styles not being applied (intermitent)
                                    Hakan Moral Newbie

                                    insert the page element at the beginning of your pages.xml and it will reload the css's.


                                    <page view-id="/stylesheet/**" login-required="false">