Search code examples
grailsresourcesabsolute-path

Grails resource warning log entry when using images with absolute:true


Using Grails 2.0.4. In building emails, I use a lot of images with absolute paths. Each one results in an annoying log entry. Is there an easy fix? They DO exist, it just seems the resource plugin doesn't like absolute paths. This happens outside of localhost / dev environment too.

<img src="${resource(dir: 'images/brochure', file: 'arrow_up.png', absolute: 'true')}" alt="Up" />

results in

WARN  resource.ResourceTagLib  - Invocation of <r:resource> for a resource that apparently doesn't exist: http://localhost:8080/images/brochure/arrow_up.png

Solution

  • The solution that has been working with me for Grails 2.1.x and above (including the newest 2.3.x) is adding these entries to your log4j config block in Config.groovy - no other code changes needed.

     log4j = {
               //your other stuff ...
                error 'grails.app.services.org.grails.plugin.resource'
                error 'grails.app.taglib.org.grails.plugin.resource'
                error 'grails.app.resourceMappers.org.grails.plugin.resource'
    }