title: Groovy No signature of method calling Java library
body: <p>As many questions begin, this is driving me crazy.</p>
  
  <p>I have a homegrown <code>StarTeam</code> java library. I have one static method like this:</p>
  
  <pre><code>public static Label getLatestDeploymentLabel(com.starbase.starteam.File child) {
   // blah
  }
  </code></pre>
  
  <p>The method works as expected when I call it from java. When I call it from Groovy, I get:</p>
  
  <pre><code>Caught: groovy.lang.MissingMethodException: 
  No signature of method: static pkg.starteam.StarTeamUtils.getLatestDeploymentLabel() 
  is applicable for argument types: (com.starbase.starteam.File) 
  values: [FILENAME-FOO.sql] at starteam.run(starteam.groovy:54)
  </code></pre>
  
  <p>I put in a <code>println</code> right before I call that method:</p>
  
  <pre><code>chgset.elements().each() { item -&gt;
    println "type of item is ${item.class.getName()}"
    def latestlabel = StarTeamUtils.getLatestDeploymentLabel(item)
  }
  </code></pre>
  
  <p>And confirm that, in fact, it's iterating what I expect it's iterating over:</p>
  
  <p><code>type of item is com.starbase.starteam.File</code></p>
  
  <p>I've seen a few different similar issues in other posts relating to static methods and the responses are along the lines of "are you sure it's a static method?".  I'm sure it's a static method.</p>
  
  <p>There isn't much groovy code to this.  What there is of it is all contained in a single script in the default package.  The main method is then called implicitly and it's in the body of the script class that the call out to the java library is made.  I set the classpath in a DOS batch wrapper script, e.g.:</p>
  
  <pre><code>SET INITIALCLASSPATH=%CLASSPATH%
  SET NEWCP=c:/libs/etc.jar;c:/etc/etc.jar
  SET GROOVYPATH=c:/groovy.bat
  SET CLASSPATH=%NEWCP%
  %GROOVYPATH% %*
  SET CLASSPATH=%INITIALCLASSPATH%
  </code></pre>
  
  <p>I created a simple situation which I <em>think</em> emulates my situation.  </p>
  
  <pre><code>C:\apps\groovy-1.8.6\scripts&gt;type Other.java
  class Other {
      private String name = "notset";
      public Other(String name) {
          this.name = name;
          System.out.println("Created an other");
      }
      public String toString() {
          return name;
      }
  }
  C:\apps\groovy-1.8.6\scripts&gt;type ThingList.java
  import java.util.ArrayList;
  import java.util.Iterator;
  
  class ThingList {
      ArrayList ourlist = new ArrayList&lt;Other&gt;();
      public ThingList(){}
      public ArrayList add(Other thing) {
          ourlist.add(thing);
          return ourlist;
      }
      public Iterator iterator(){
          return ourlist.iterator();
      }
  }
  C:\apps\groovy-1.8.6\scripts&gt;type JavaLib.java
  class JavaLib {
      public JavaLib() {}
      public static ThingList getThingList(Other thing) {
          ThingList tl = new ThingList();
          Other one = new Other("extra one");
          tl.add(thing);
          tl.add(one);
          return ThingList;
      }
  }
  C:\apps\groovy-1.8.6\scripts&gt;type testthing.groovy
  def myOther = new Other("A new other")
  println "type of myOther is ${myOther.class.getName()}"
  def myList = getThingList(myOther)
  myList.each() {
    println it
  }
  C:\apps\groovy-1.8.6\scripts&gt;type wrapper.bat
  @ECHO OFF
  SET INITIALCLASSPATH=%CLASSPATH%
  SET GROOVY=C:\apps\groovy-1.8.6\bin\groovy.bat
  SET CP=.
  SET CLASSPATH=%CP%
  
  %GROOVY% %*
  
  SET CLASSPATH=%INITIALCLASSPATH%
  C:\apps\groovy-1.8.6\scripts&gt;wrapper.bat testthing.groovy
  Created an other
  type of myOther is Other
  Caught: groovy.lang.MissingMethodException: No signature of method: testthing.ge
  tThingList() is applicable for argument types: (Other) values: [A new other]
  groovy.lang.MissingMethodException: No signature of method: testthing.getThingLi
  st() is applicable for argument types: (Other) values: [A new other]
          at testthing.run(testthing.groovy:3)
  
  C:\apps\groovy-1.8.6\scripts&gt;
  </code></pre>
  
  <p>Any insights or suggestions would be greatly appreciated!</p>
  
  <p>AndyJ</p>