0

Grails 2.3.7 and the cached resources plugin, at least with lesscss resources are not working properly.

The cached plugin returns an erro which is the same error as described in this thread:

<dt>Class</dt><dd>java.lang.NullPointerException</dd><dt>Message</dt><dd>Cannot invoke method cache() on null object</dd></dl><h2>Around line 31 of <span class="filename">grails-app/resourceMappers/org/grails/plugin/cachedresources/HashAndCacheResourceMapper.groovy</span></h2>
<pre class="snippet"><code class="line"><span class="lineNumber">28:</span> if (log.debugEnabled) {</code><code class="line"><span class="lineNumber">29:</span> log.debug &quot;Setting caching headers on ${req.requestURI

http://grails.1312388.n4.nabble.com/Grails-resources-bug-Unable-to-load-resources-at-startup-td4652307.html

The problem is that cacheHeadersService is not injected or null in the cacheheaders plugin.

Trying to solve this I copied the contents of the cached-resources-plugin 1.1 from target/work/plugins to a local folder and added the following line:

grails.plugin.location.'cached-resources' = "../grailsplugins/cached-resources-1.1"

The intention was to fix this bug myself.

However, strangely enough, when the plugin is locally used the problem with injecting the cacheHeadersService is gone!

How can the plugin act differently when used locally versus when installed normally?

Perhaps it is a loader issue where now the cache-resources-plugin is loaded after whatever is declaring the service, but nonetheless worth reporting.

In the dependencies.groovy in the cache-resources plugin it declares the dependency:

compile ":cache-headers:1.0.4"

but obviosuly it is not loaded before the plugin unless loaded from local directory, strange!

I am also wondering, since the cache-resources plugin declares a dependency on tomcat :

 build(":tomcat:$grailsVersion",
              ":release:2.0.3",
              ":rest-client-builder:1.0.2") {
            export = false
        }

is tomcat a requirement? Trying to change to Jetty in the main application the build process fails, saying that tomcat can not be found in the repository.

build  ":jetty:2.0.3"// ":tomcat:7.0.52.1"

I just found these similar questions as well:

Cached-resources plugin is not working? Grails Cache resources not working Resource not found on grails appliction with cache plugins

Community
  • 1
  • 1
Samson
  • 107
  • 1
  • 6
  • cached resources is not dependent on tomcat. Notice the export=false line. This is here simply to facilitate running integration and functional tests within the plugin itself. Also are you sure that the version you cloned from github is the version that was published. i.e. have changes been made to fix this just not published to the grails.org/plugins. – davydotcom May 13 '14 at 12:22
  • @davydotcom No, I am using the plugin from the repo, not from github. Perhaps I need to check out that version and give it a go :) – Samson May 13 '14 at 13:41

0 Answers0