Resources Plugin
  1. Resources Plugin
  2. GPRESOURCES-102

Problem with CSS bundles after upgrading to Grails 2.0.0.RC1/Resources 1.1.1

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.1
    • Fix Version/s: 1.2-RC1
    • Labels:
      None
    • Environment:
      Windows XP SP3, Java 1.6.0_27

      Description

      Quoting from the mailing list (http://grails.1312388.n4.nabble.com/Problem-with-css-resources-after-upgrading-to-2-0-0-RC1-tp3928501p3928501.html)

      Hi there,

      After upgrading my app to Grails 2.0.0.RC1/Resources 1.1.1, it seems that CSS resources declared in ApplicationResources.groovy stopped working properly.

      More specifically, the <link rel="stylesheet" .../> tags generated by <r:layoutResources /> for CSS bundles are missing the ".../static/..." part in the URL, thus resulting in 404 errors.

      Here's an example of how one of my CSS bundles looked likee with Grails 2.0.0.M2 and Resources 1.0.2:
      <link href="/myapp/static/bundle-myapp_head.css" type="text/css" rel="stylesheet" media="screen, projection" />

      and here's how it looks now with Grails 2.0.0.RC1 and Resources 1.1.1:
      <link href="/myapp/bundle-myapp_head.css" type="text/css" rel="stylesheet" media="screen, projection" />

      Note 1: the same goes for CSS resources provided by plugins (e.g. by twitter-bootstrap)
      Note 2: the contents of the bundles that end up under \.grails\2.0.0.RC1\projects\myapp\tomcat\work\Tomcat\localhost\myapp\grails-resources are empty
      Note 3: JS bundles seem to be working fine (i.e. they include the /static/ part in the URL).
      Note 4: I tested this using Windows XP SP3

      Anyone facing the same problem?

      Many thanks,
      Dimitris

      1. resources-bug.png
        51 kB
      2. test-resources-notok.png
        65 kB
      3. test-resources-ok.png
        65 kB

        Activity

        Hide
        sudhir added a comment -

        Seems I have found the source of the problem, and it lies in the resources plugin itself not in cached resources, cached resources just triggers the bug.

        The issue is - When you have a js file defined in its own bundle and you use that same js in any other bundle rather then using dependsOn (because you want to bundle that file togather with other js files) and if you have cached resource plugin installed, it will trigger this bug. Why - because once the first bundle containing that js file is processed by the hashandcache mapper, the file would have been renamed, when second bundle tries to process the file it won't find it.

        Here's what I see in logs
        2012-07-31 13:49:52,207 [main] WARN org.grails.plugin.resource.ResourceProcessor - C:\Users\Sudhir\.grails\1.3.7\projects\PROJECT-NAME\tomcat\work\Tomcat\localhost\sbi\grails-resources\j\jquery.cookie.js (The system cannot find the file specified)

        I have a bundle

             'jquery-cookie' {
                 resource id:'js', url:[dir:'j', file:'jquery.cookie.js'], disposition:'defer'
             }
        

        And one another bundle

        'bundle-two'

        { resource id:'cookie-js', url:[dir:'j', file:'jquery.cookie.js'], disposition:'head' ... ... ... //some other js/css resources }

        Here bundle-two has the issue - and when bundle-two is being processed on server start - I see below line in server logs
        2012-07-31 13:49:52,207 [main] WARN org.grails.plugin.resource.ResourceProcessor - C:\Users\Sudhir\.grails\1.3.7\projects\PROJECT-NAME\tomcat\work\Tomcat\localhost\sbi\grails-resources\j\jquery.cookie.js (The system cannot find the file specified)

        Hope it helps in reproducing and fixing the issue.

        Show
        sudhir added a comment - Seems I have found the source of the problem, and it lies in the resources plugin itself not in cached resources, cached resources just triggers the bug. The issue is - When you have a js file defined in its own bundle and you use that same js in any other bundle rather then using dependsOn (because you want to bundle that file togather with other js files) and if you have cached resource plugin installed, it will trigger this bug. Why - because once the first bundle containing that js file is processed by the hashandcache mapper, the file would have been renamed, when second bundle tries to process the file it won't find it. Here's what I see in logs 2012-07-31 13:49:52,207 [main] WARN org.grails.plugin.resource.ResourceProcessor - C:\Users\Sudhir\.grails\1.3.7\projects\PROJECT-NAME\tomcat\work\Tomcat\localhost\sbi\grails-resources\j\jquery.cookie.js (The system cannot find the file specified) I have a bundle 'jquery-cookie' { resource id:'js', url:[dir:'j', file:'jquery.cookie.js'], disposition:'defer' } And one another bundle 'bundle-two' { resource id:'cookie-js', url:[dir:'j', file:'jquery.cookie.js'], disposition:'head' ... ... ... //some other js/css resources } Here bundle-two has the issue - and when bundle-two is being processed on server start - I see below line in server logs 2012-07-31 13:49:52,207 [main] WARN org.grails.plugin.resource.ResourceProcessor - C:\Users\Sudhir\.grails\1.3.7\projects\PROJECT-NAME\tomcat\work\Tomcat\localhost\sbi\grails-resources\j\jquery.cookie.js (The system cannot find the file specified) Hope it helps in reproducing and fixing the issue.
        Hide
        sudhir added a comment -

        And I forgot to mention that if i remove jquery.cookie.js from bundle-two - the bundle starts working fine.

        Show
        sudhir added a comment - And I forgot to mention that if i remove jquery.cookie.js from bundle-two - the bundle starts working fine.
        Hide
        sudhir added a comment -

        Should this issue be reopened?

        Show
        sudhir added a comment - Should this issue be reopened?
        Hide
        sudhir added a comment -

        @mark - do you think this issue needs to be resolved or it's 'wont-fix' ?

        Show
        sudhir added a comment - @mark - do you think this issue needs to be resolved or it's 'wont-fix' ?
        Hide
        Keith Ganger added a comment -

        We are also seeing this issue with resources 1.2.RC2 and grails 2.2.3. @sudhir seems to have the correct root of this issue.

        Why is this closed as cannot reproduce. There are a lot of people who have given cases to reproduce this problem. Can this at least be opened up and tracked. Or should I write up a new bug report for the issue?

        Show
        Keith Ganger added a comment - We are also seeing this issue with resources 1.2.RC2 and grails 2.2.3. @sudhir seems to have the correct root of this issue. Why is this closed as cannot reproduce. There are a lot of people who have given cases to reproduce this problem. Can this at least be opened up and tracked. Or should I write up a new bug report for the issue?

          People

          • Assignee:
            Marc Palmer
            Reporter:
            Dimitris Zavaliadis
          • Votes:
            16 Vote for this issue
            Watchers:
            21 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: