Alex Rivera | Logout

Java "NoSuchMethodError"

Asked 2010-09-12T15:19:18.087
28

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.

Edit
Report

2 Answers

25

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.

answered 2010-09-12T15:27:50.643
2

I noticed this problem occurring while testing some experimental changes in multiple linked projects, after updating them from SVN in Eclipse.

Specifically, I updated all projects from SVN, and reverted the .classpath file rather than edit it manually to keep things simple.

Then I re-added the linked projects to the path, but forgot to remove the related jars. This was how the problem occurred for me.

So apparently the run time used the jar file while the compiler used the project files.

answered 2012-01-27T19:21:25.203

Your Answer