title: Applying Groovy extensions in Grails produces MissingMethodException for String#toBoolean()
body: <h2>Background</h2>
  
  <p>Groovy have the feature of <a href="http://docs.codehaus.org/display/GROOVY/Creating+an+extension+module" rel="nofollow">adding methods to the existing classes</a>, and I've found <a href="https://github.com/timyates/groovy-common-extensions" rel="nofollow">some</a> <a href="https://github.com/ataylor284/groovy-crypto-extensions" rel="nofollow">interesting</a> ones.</p>
  
  <p>Then I <a href="http://grails.1312388.n4.nabble.com/groovy-extension-module-and-grails-td4642249.html" rel="nofollow">discovered</a> that I need to customize my Grails bootstrap to load them, so I add:</p>
  
  <pre><code>def init = { servletContext -&gt; addExtensionModules() }
  
    def addExtensionModules() {
  
      Map&lt;CachedClass, List&lt;MetaMethod&gt;&gt; map = [:]
      ClassLoader classLoader = Thread.currentThread().contextClassLoader
      try {
        Enumeration&lt;URL&gt; resources = classLoader.getResources(MetaClassRegistryImpl.MODULE_META_INF_FILE)
        for (URL url in resources) {
          if (url.path.contains('groovy-all')) {
            // already registered
            continue
          }
          Properties properties = new Properties()
          InputStream inStream
          try {
            inStream = url.openStream()
            properties.load(inStream)
            GroovySystem.metaClassRegistry.registerExtensionModuleFromProperties(properties,
                              classLoader, map)
          }
          catch (IOException e) {
            throw new GroovyRuntimeException("Unable to load module META-INF descriptor", e)
          } finally {
            inStream?.close()
          }
        }
      }  catch (IOException ignored) {}
      map.each { CachedClass cls, List&lt;MetaMethod&gt; methods -&gt;
      cls.setNewMopMethods(methods)
    }
  }
  </code></pre>
  
  <p>And I add in my BuildConfig.groovy</p>
  
  <pre><code>compile ('ca.redtoad:groovy-crypto-extensions:0.2') {
    excludes 'groovy-all'
  }
  </code></pre>
  
  <h2>The Question</h2>
  
  <p>The problem is that now I cannot use the <code>toBoolean()</code> method of Groovy String:</p>
  
  <blockquote>
    <p>groovy.lang.MissingMethodException: No signature of method:
    java.lang.String.toBoolean() is applicable for argument types: ()
    values: [] Possible solutions: asBoolean(), asBoolean(), toFloat(),
    toDouble()</p>
  </blockquote>
  
  <p>Since groovy is already registered, why the method is missing? I'm using Grails 2.2.4.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Tested in a groovy 2.0.8 console, and the code works, so probably is something related to Grails.</p>
  
  <pre><code>@Grab('ca.redtoad:groovy-crypto-extensions:0.2')
  @GrabExclude('org.codehaus.groovy:groovy-all')
  
  addExtensionModules() //same method of BootStrap, ommited to make shorter.
  
  def key = "password".toKey()
  def ciphertext = "some plaintext".bytes.encrypt(key: key)
  def x = new String(ciphertext.decrypt(key: key)).toBoolean()
  println "S".toBoolean()
  </code></pre>