Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

314
Views
Java NoSuchMethodError when Method Exists

I am referencing PlayerUtil.getMovementSpeed(player); in my Speed class, and in my PlayerUtil class, I have the method defined as:

public static double getMovementSpeed(Player player) {
  //my code here
}

But whenever the getMovementSpeed method is referenced in my other classes, it throws this error:

java.lang.NoSuchMethodError: net.Swedz.util.PlayerUtil.getMovementSpeed(Lorg/bukkit/entity/Player;)D

I thought it may be that Eclipse was exporting incorrectly, but I rebooted it and tried again with no avail.

EDIT: I did try decompiling the exported jar, and the public static double getMovementSpeed(Player player) method does exist in the exported jar.

EDIT: My friend is also having a similar issue, and is using IntelliJ, so Eclipse is not the issue.

EDIT: Class definition for PlayerUtil:

package net.Swedz.util;

public class PlayerUtil implements Listener {
    //getMovementSpeed is defined in here
}

Class definition for Speed:

package net.Swedz.hack.detect.move;

public class Speed implements Hack, Listener {
    //my detection methods and method containing PlayerUtil.getMovementSpeed(player);
}

SOLUTION: I found on my own that I had classes conflicting between two plugins on my server. I had one jar with net.Swedz.util.PlayerUtil and another with net.Swedz.util.PlayerUtil both with different contents. I added my project name in all lower case after the net.Swedz and it seems to have fixed it!

Thanks!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is a very simple to troubleshoot. you have used that method and you were able to compile that class which uses this method.

so that means at compile time it reefers the class PlayerUtil which has this method.

But runtime class loader has loaded the class PlayerUtil which doesn't contain this method. now what you have to do is just find out where that class has been loaded from (at run time)

if you can recreate the problem while it is running using eclipse/IDEA follow these steps. (if it runs in in application server or standalone application, then start the application server or application with debug enabled.and you can do remote debug from your IDE).

  1. put a break-point where exception was thrown (where you call this method).
  2. start to debug , it will hit the break-point.
  3. then evaluate this expression PlayerUtil.class.getResource("PlayerUtil.class")

4.you can find the path where the class was loaded from.

now you have two options , decompile the class and check whether that method is these (same return type, same name , same args).

or in debug , you can evaluate PlayerUtil.class.getDeclaredMethods() to find out.

So you can solve the problem by rectifying the class path entries if it was loaded from a wrong place.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!