title: Spock tests failing after grails upgrade 2.2 -> 2.3.7
body: <p>I have a command object with a couple of static methods which access other domain objects.</p>
  
  <pre><code>static def isAValidSerial(String serialReference) {
     return InventoryMaster.partSerialReferenceList(null, serialReference).size() &gt; 0
  }
  </code></pre>
  
  <p>This method is called by the validation constraints on the command object.</p>
  
  <p>In a unit test I mock this behavior.</p>
  
  <pre><code>TransactionDetailCommand.metaClass.static.isAValidSerial = { String a -&gt; println "mocked method called"; true }
  </code></pre>
  
  <p>before invoking some validation:</p>
  
  <pre><code>obj.validate(['serialReference'])
  </code></pre>
  
  <p>However this is throwing an exception where it didn't with 2.2.0. </p>
  
  <p>The error is: </p>
  
  <p><code>java.lang.IllegalStateException: Method on class [com.myStuff.MyClass] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.</code></p>
  
  <p>Despite the mocking when it's called from the validator it appears to be trying to invoke the real method and not the mock. If I put an explicit <em>println</em> <strong>before</strong> the obj.validate() it correctly prints the test text from the mocked method and returns the mocked value. This worked on 2.2 but now fails. I <strong>didn't</strong> used the grails update command. I created a new project and copied stuff to it. I've found various tips including removing the forked JVM stuff from the build config but nothing seems to work. </p>
  
  <p>Anyone any ideas? Thanks.</p>