Search code examples
grailsasset-pipelineshiro

Grails asset-pipeline - nothing available


I have a Grails app which currently runs under 2.2.4. I decided to upgrade it to 2.4.0, and in doing so convert it to use the asset-pipeline for my css/js/images. I placed all my old resources in the new assets/... directories.

I'm using IntelliJ 12.1.7 to run the app in debug-mode for development. The app starts just fine, but none of my assets seem to be available. Tomcat 7.0.52.1. Java 7.0.55. I see references such as "main.css?compile=false" in the raw html, but the asset itself isn't available when I try to view it directly in the browser (http:\localhost:8080\assets\stylesheets\main.css). I'll also show my ignorance here a bit and ask what the "?compile=false" is. That's new to me.

I ran "grails clean". Are there any changes I need to make in config.groovy or any other files? I did make the changes to remove references to the old "resources" system per the Grails documentation.

Any ideas why the assets don't seem to be getting picked up by the plugin?

UPDATE: something must be getting lost in the translation because when I created an app from scratch, assets loaded just fine in the way I'd expect when referenced per the documentation. I have crosschecked the settings in my BuildConfig and Config files and they match between the 2 apps. They are also using the same version of all the plugins. If I discover a solution, I'll post it here, but frankly I think my next order of business is going to be to gradually start importing the pieces from my app into the newly created one because there seems to be a setting buried somewhere that I don't know about that is getting configured during 2.4.0 creation that is not present in my old code base. Or there is some legacy "resources" plugin stuff that has not been removed. Fortunately not a huge app.

UPDATE 2: I have found the source of the issue. My app uses Apache Shiro for security and authentication. Installing the plugin doesn't cause an issue, but once I run "grails shiro-quick-start" the asset pipeline stops working. I'm adding a tag to this question in the hopes that someone with Shiro knowledge will be able to help. I have also created a bug over at the grails jira (https://jira.grails.org/browse/GPSHIRO-79)

Update 3: A workaround has been found and implemented. See the jira link above.


Solution

  • A workaround (and possibly solution) is to change the following line in ShiroSecurityFilters.groovy from

    if (!controllerName) return true
    

    to

    if (!controllerName || controllerName == 'assets') return true
    

    See update 3 in original post for details.