1
votes

I'm just starting with groovy. This error looks basic. but i don't seem to get through this. Appreciate any help in guiding me through the right direction

I'm defining a string like below and passing it to testSender method

def line = "5 1 -81.42 Ido1"
testSender(line.toString())

Definition of testSender method

def testSender(line){
     try {
         println line  
     } catch(e) {
         println e.printStackTrace()
     }
}

When I run this, getting this error

groovy.lang.MissingMethodException: 
No signature of method: GroovySQLQuery$_main_closure1.testSender() 
is applicable for argument types: (java.lang.String) values: [5 1 -81.42 Ido1]
1
Main point to note is GroovySQLQuery$_main_closure1.testSender(). Why GroovySQLQuery is referred for testSender() where testSender is just a test method which you implemented. - dmahapatro
Name of the script is GroovySQLquery.groovy. testSender is a method part of this script - skhprabu
please provide a complete example, that shows the error. putting that code into a groovy file runs fine - cfrick
class GroovySQLQuery{ static void main(String[] args) { def line = "5 1 -81.42 Ido1" testSender(line.toString()) } def testSender(line) { println line } } - skhprabu
that is the whole script.... here is the exception..... groovy.lang.MissingMethodException: No signature of method: static GroovySQLQuery.testSender() is applicable for argument types: (java.lang.String) values: [5 1 -81.42 Ido1] Possible solutions: testSender(java.lang.Object) - skhprabu

1 Answers

3
votes

Should be:

class GroovySQLQuery { 
    static void main(String[] args) { 
        def line = "5 1 -81.42 Ido1" 
        testSender(line.toString()) 
    } 

    static testSender(line) { 
        println line 
    } 
}