groovymissingmethodexception

MissingMethodException in Groovy: No signature of method


When using the following piece of code in Groovy...

def printDocument(deviceName, document, resolution, documentName, creatorName, xOffset, yOffset, startPage, endPage, numCopies) {
    // do stuff...
)

printDocument(
    'Printer name',
    'C:/temp/test.pdf',
    600,
    'My document',
    'John Doe',
    0,
    0,
    0,
    0,
    1)

... I get the following exception:

Caught: groovy.lang.MissingMethodException: No signature of method printDocument() is applicable for argument types (java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer)

As far as I can see the number of arguments are correct. Any ideas why this method call fails?


Solution

  • You close the method with a ) not a } then it works fine in the groovy console

    Should be:

    def printDocument(deviceName, document, resolution, documentName, creatorName, xOffset, yOffset, startPage, endPage, numCopies) {
        // do stuff...
    }
    

    Unless of course you have pasted something which works in to the question by mistake?

    If that doesn't fix your issue, can you find/write some code that exhibits the problem in the context you are having the issue with?