title: Groovy Mixins?
body: <p>I'm trying to mix-in a class in my Groovy/Grails app, and I'm using <a href="http://docs.codehaus.org/display/GroovyJSR/Mixins#Mixins-StaticMixing" rel="noreferrer">the syntax defined in the docs</a>, but I keep getting an error.</p>
  
  <p>I have a domain class that looks like this:</p>
  
  <pre><code>class Person {
    mixin(ImagesMixin)
  
    // ...
  }
  </code></pre>
  
  <p>It compiles fine, but for some reason it won't work. The file containing ImagesMixin is located in my <code>/src/groovy/</code> directory.</p>
  
  <p>I've tried it using Groovy versions 1.5.7 and 1.6-RC1 without any luck. Does anyone know what I'm doing wrong?</p>
  
  <p>stacktrace:</p>
  
  <pre><code>2008-12-30 17:58:25.258::WARN:  Failed startup of context org.mortbay.jetty.webapp.WebAppContext@562791{/FinalTransmission,/home/kuccello/Development/workspaces/lifeforce/FinalTransmission/web-app}
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
      at java.security.AccessController.doPrivileged(Native Method)
      at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:67)
      at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy)
      at Init_groovy$_run_closure6.doCall(Init_groovy:131)
      at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:66)
      at RunApp_groovy$_run_closure2.doCall(RunApp_groovy)
      at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:57)
      at RunApp_groovy$_run_closure1.doCall(RunApp_groovy)
      at gant.Gant.dispatch(Gant.groovy:271)
      at gant.Gant.this$2$dispatch(Gant.groovy)
      at gant.Gant.invokeMethod(Gant.groovy)
      at gant.Gant.processTargets(Gant.groovy:436)
      at gant.Gant.processArgs(Gant.groovy:372)
  Caused by: java.lang.ExceptionInInitializerError
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at Episode.class$(Episode.groovy)
      at Episode.&lt;clinit&gt;(Episode.groovy)
      ... 13 more
  Caused by: groovy.lang.MissingMethodException: No signature of method: static Person.mixin() is applicable for argument types: (java.lang.Class) values: {class ImagesMixin}
      at Broadcast.&lt;clinit&gt;(MyClass.groovy:17)
      ... 17 more
  2008-12-30 17:58:25.259::WARN:  Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError:
  groovy.lang.MissingMethodException: No signature of method: Person.mixin() is applicable for argument types: (java.lang.Class) values: {class ImagesMixin}
      at Broadcast.&lt;clinit&gt;(Person.groovy:17)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at Episode.class$(BelongsToMyClass.groovy)
      at Episode.&lt;clinit&gt;(BelongsToMyClass.groovy)
      at java.security.AccessController.doPrivileged(Native Method)
      at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:67)
      at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy)
      at Init_groovy$_run_closure6.doCall(Init_groovy:131)
      at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:66)
      at RunApp_groovy$_run_closure2.doCall(RunApp_groovy)
      at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:57)
      at RunApp_groovy$_run_closure1.doCall(RunApp_groovy)
      at gant.Gant.dispatch(Gant.groovy:271)
      at gant.Gant.this$2$dispatch(Gant.groovy)
      at gant.Gant.invokeMethod(Gant.groovy)
      at gant.Gant.processTargets(Gant.groovy:436)
      at gant.Gant.processArgs(Gant.groovy:372)
  2008-12-30 17:58:25.271::INFO:  Started SelectChannelConnector@0.0.0.0:8080
  </code></pre>