Grails - No signature of method is applicable for argument types

18,136

Your exception correctly states that the method Replicate.create() is not available to the controller. Check the following,

1. You have imported the class right.
2. Package name is correct.
3. You have cleaned your application.

Try all the three mentioned above, it might help if the method is working on other places.

Share:
18,136
unlimitednzt
Author by

unlimitednzt

Updated on June 04, 2022

Comments

  • unlimitednzt
    unlimitednzt almost 2 years

    I'm starting with Grails (using mainly the Eclipse plugin) and have been having trouble with Grails reading Java src files - whether it's a jar in the bin folder, or a Java file in the src/java folder.

    I've created an example of how I call from my controller, a Java static method, and for some reason there is a problem with the argument type. Here's the controller:

    def attempt = {
        int counter = 20
        int val1 = 1
        int val2 = 1
        def list = Replicate.create(counter, val1, val2)
        render list.size()
    }
    

    And here is the Java file in the src/Java folder:

    public class Replicate {
    
    public static LinkedList<Pair<Integer, Integer>> create (int count, int val1, int val2){
    
        LinkedList<Pair<Integer, Integer>> list = new LinkedList<Pair<Integer,Integer>>();
    
        for (int i = 0; i < count; i++){
            list.add(new Pair<Integer, Integer>(val1, val2));
        }
    
        return list;
    }
    }
    

    When I try and load the page for the Controller's method, I get:

    URI:
    /clive-toolbox/cliveServices/attempt
    Class:
    groovy.lang.MissingMethodException
    Message:
    No signature of method: static tst.Replicate.create() is applicable for argument types:     (java.lang.Integer, java.lang.Integer, java.lang.Integer) values: [20, 1, 1] Possible solutions:     grep(), iterator()
    

    The line that is highlighted as the error is this (in the controller):

    def list = Replicate.create(counter, val1, val2)
    

    And in other cases, working the same way, Grails manages to compile the project but just doesn't execute the method. I assume I'm doing something wrong. Any ideas here?