Java "NoSuchMethodError"

vrm picture vrm · Sep 12, 2010 · Viewed 48.8k times · Source

I'm getting:

NoSuchMethodError: com.foo.SomeService.doSmth()Z

Am I understanding correctly that this 'Z' means that return type of doSmth() method is boolean? If true, then that kind of method really does not exist because this method returns some Collection. But on the other hand if I call this method, I'm not assigning its return value to any variable. I just call this method like this:

service.doSmth();

Any ideas why this error occurs? All necessary JAR files exist and all other methods from this class seems to exist.

Answer

amorfis picture amorfis · Sep 12, 2010

Looks like method exists in classpath during compilation, but not during running of your application.

I don't think return type is a problem. If it was, it wouldn't compile. Compiler throws error when method call is ambiguous, and it is when two methods differ only by return type.