Skip to content

Instantly share code, notes, and snippets.

@mathifonseca
Created October 27, 2014 14:34
Show Gist options
  • Save mathifonseca/4321cab97904305a4480 to your computer and use it in GitHub Desktop.
Save mathifonseca/4321cab97904305a4480 to your computer and use it in GitHub Desktop.
GRAILS - Don't use this packages!

This is not Grails fault, but Spring-Loaded's.

They make the assumption that you won't put any of your own code under a package called in certain ways, and caches classes under that packages, which are meant to be used only by the framework. The most significant ones for us are grails.* and groovy.*. As a result, if you do use that packages, you will get something like this when trying to reload those classes:

2014-09-26 04:21:20,945 [FileSystemWatcher: files=#100 cl=java.net.URLClassLoader@
19d86dfc] ERROR plugins.AbstractGrailsPluginManager  - Plugin [services:2.4.2] could not reload changes to file [/<path to ggts workspace>/ggts-workspace/grails-slow3/grails-app/services/slow/SomeClassService.groovy]: Cannot get property 'cacheOperationSource' on null object
Message: Cannot get property 'cacheOperationSource' on null object
   Line | Method
->> 184 | doCall in CacheGrailsPlugin$_closure4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
^   745 | run    in java.lang.Thread

Here is the source code that explains it:

https://github.com/spring-projects/spring-loaded/blob/master/springloaded/src/main/java/org/springsource/loaded/TypeRegistry.java#L78

The solution:

Always namespace your packages with your apps' or company's name. Avoid getting your classes confused with the framework classes.

@lucianosantanabr
Copy link

@mr-simonski, Hi, did you solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment