MissingMethodException hiding underlying exception


(kshaw) #1

This might be a groovy question. Sorry, if that is the case.

With code like:

def t = new Test() def h = new Handler() t.test(something(h))

Sometimes I get error messages like:

groovy.lang.MissingMethodException: No signature of method test.Test.test() is applicable for argument types: (test.Handler) values: [test.Handler@82eaf9]. Possible solution: test(test.Handler)

That appears to happen because an error occurred somewhere within something.

How do you debug this type of error? A stack trace doesn’t include the actual error. So, I start changing values in places to try to triangulate toward the error. Is there a feature that would allow me to debug this more easily?


(Peter Niederwieser) #2

Groovy’s ‘MissingMethodException’ means that no method with the given name exists, or that the method with the given name takes different argument types. Subtle causes include instance/static method mismatch and class loader conflicts. First thing to do is to consult the API docs.


(kshaw) #3

I should have pointed out more explicitly that the error message is saying that there is no method with that signature and suggest the same signature as a solution. When I have had this type of error where the suggested solution is the same as problem being complained about, the ultimate solution has been something unrelated and the method signature that is the subject of the error message is not changed.


(Peter Niederwieser) #4

I should have pointed out more explicitly that the error message is saying that there is no method with that signature and suggest the same signature as a solution.

I don’t know how that could occur other than due to a class loader conflict.