Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError, with both classes in the same JAR!

My Java skills are a little rusty, but this is really weird: I am getting a java.lang.NoSuchMethodError at runtime when calling a method in a different class - note that the code compiled fine - and the other class is contained in the same JAR as the calling method!

That would seem to indicate it's not a classpath issue - but then what?

like image 514
Shaul Behr Avatar asked Jul 03 '11 17:07

Shaul Behr


1 Answers

Check out this article. http://snippets.dzone.com/posts/show/3719

URL myClassURL = MyMysteryClass.class.getProtectionDomain().getCodeSource().getLocation();

That will tell you exactly where your class is being loaded from (according to the article). Should clear up any classpath questions.

like image 74
DaveC Avatar answered Oct 16 '22 23:10

DaveC