[SOLVED] NoSuchMethodError

Discussion in 'Plugin Development' started by acuddlyheadcrab, Apr 9, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    acuddlyheadcrab

    EDIT3: I fixed it guys. What I ended up doing is taking to two classed that had errors, copying the text, deleting them and pasting their text into a similarly named but different class file. The classpath thought that PluginIO.java and Util.java didn't exist, so I made it so they really don't, therefore the classpath was synced again.


    Second post:
    Show Spoiler

    Could somebody help me out with this? I'm running out of ideas. Even my last option ideas didn't work!

    (I'm getting a NoSuchMethodError, no matter what project, IDE, system I compile it on. All my other plugins are able to compile correctly. AND the error doesn't happen when the plugin is by itself in a servers plugin folder)

    Original post:
    Show Spoiler

    This is definitely a bug I can't squash. Like the thread title says, I'm getting a NoSuchMethodError when my main class is initialized.

    (EDIT: The error happens in 1.2.5 as well.)
    Code:
    21:54:04 [INFO] This server is running CraftBukkit version git-Bukkit-1.2.4-R1.0-b2126jnks (MC: 1.2.
    4) (Implementing API version 1.2.4-R1.0)
    21:54:04 [SEVERE] Could not load 'plugins\MCHungerGames.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NoSuchMethodError: com.acuddlyheadcrab.Util.Plug
    inIO.<init>(Lcom/acuddlyheadcrab/MCHungerGames/HungerGames;)V
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:148)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)
            at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183)
            at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53
    )
            at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.lang.NoSuchMethodError: com.acuddlyheadcrab.Util.PluginIO.<init>(Lcom/acuddlyheadcra
    b/MCHungerGames/HungerGames;)V
            at com.acuddlyheadcrab.MCHungerGames.HungerGames.<init>(HungerGames.java:23)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)
            ... 8 more
    I've seen that sometimes this can happen when inherited bukkit methods are messed up and stuff, but the error refers to HungerGames.java:23 which is where I instantiate my PluginIO class...


    It's current source is on github (main errors at com.acuddlyheadcrab.MCHungerGames.HungerGames.java and com.acuddlyheadcrab.Util.PluginIO.java)

    Here's the source of my main class
    Show Spoiler
    Code:java
    1. package com.acuddlyheadcrab.MCHungerGames;
    2.  
    3. import java.util.List;
    4.  
    5. import org.bukkit.Material;
    6. import org.bukkit.configuration.file.FileConfiguration;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.inventory.ItemStack;
    9. import org.bukkit.inventory.PlayerInventory;
    10. import org.bukkit.plugin.PluginDescriptionFile;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. import com.acuddlyheadcrab.MCHungerGames.Commands.CornucopiaCommand;
    14. import com.acuddlyheadcrab.MCHungerGames.Commands.HGArenaCommand;
    15. import com.acuddlyheadcrab.MCHungerGames.Commands.HGArenaEditCommand;
    16. import com.acuddlyheadcrab.MCHungerGames.Commands.HGGameCommand;
    17. import com.acuddlyheadcrab.MCHungerGames.Commands.HungerGamesCommand;
    18. import com.acuddlyheadcrab.Util.PluginIO;
    19.  
    20. public class HungerGames extends JavaPlugin {
    21.  
    22. public static HungerGames plugin;
    23. public static PluginDescriptionFile plugdes;
    24. public static FileConfiguration config;
    25. public static List<Arena> arenalist;
    26.  
    27. public HGListener hglistener = new HGListener(this);
    28. public PluginIO pluginio = new PluginIO(this);
    29.  
    30. @Override
    31. public void onEnable() {
    32. loadConfig();
    33. initCommands();
    34. plugdes = getDescription();
    35. System.out.println("PLUGDESC NAME: "+plugdes.getName());
    36. getServer().getPluginManager().registerEvents(hglistener, this);
    37. }
    38.  
    39. @Override
    40. public void onDisable() {
    41. PluginIO.sendPluginInfo("is now disabled");
    42. }
    43.  
    44. public void initCommands(){
    45. getCommand("hungergames").setExecutor(new HungerGamesCommand(this));
    46. getCommand("hgarena").setExecutor(new HGArenaCommand(this));
    47. getCommand("hgaedit").setExecutor(new HGArenaEditCommand(this));
    48. getCommand("hggame").setExecutor(new HGGameCommand(this));
    49. getCommand("spawnccp").setExecutor(new CornucopiaCommand(this));
    50. }
    51.  
    52. public void loadConfig() {
    53. config = getConfig();
    54. config.options().copyDefaults(true);
    55. saveConfig();
    56. }
    57.  
    58. public static JavaPlugin getPlugin(){
    59. return plugin;
    60. }
    61.  
    62. public static FileConfiguration getInstConfig(){
    63. /** Only safe AFTER plugin is enabled */
    64. if(config==null){throw new NullPointerException("CONFIG IS NULL!");} else return config;
    65. }
    66.  
    67. public boolean hasInventoryBeenCleared(Player player) {
    68. PlayerInventory inventory = player.getInventory();
    69.  
    70. for (ItemStack item : inventory.getContents())
    71. if (!(item==null||item.getType().equals(Material.AIR))) return false;
    72.  
    73. for (ItemStack item : inventory.getArmorContents())
    74. if (!(item==null||item.getType().equals(Material.AIR))) return false;
    75.  
    76. return true;
    77. }
    78.  
    79. }
    80.  


    (HungerGames.java)
    (PluginIO.java)

     
  2. Offline

    dillyg10

    Sorry, my computer is being weird w/ github, can u post the code for HungerGames here?
    Just copy and paste with the syntax = java
     
  3. Offline

    acuddlyheadcrab

    Actually I found out what this is probably a result of is me making frequent commits with git. An apparently rare bug, it's what happens when the binary files are corrupted. Since it's a run time error, it isn't caught bu Eclipse compiling it.

    I just have no idea what to do now!

    EDIT: I basically copy and pasted my whole source package folder in my project in eclipse, into a new java project... It still doesn't work...
     
  4. Offline

    dillyg10

    again, can u please post the code oh wait, i see.. ehh, u might want to make a new Eclipse project.. GitHub could have overriden the .class files..
     
  5. Offline

    acuddlyheadcrab

    I did, but I just copied the whole source folder from the old one to the new one. It should have worked but it didn't. But still, if I have to, I'll try copying the text from each java file into a new one in another project.
     
  6. Offline

    dillyg10

    I think ur gonna have to do that... this is a weird git bug, I would try keeping commiting down to a minimum :p.
     
  7. Offline

    acuddlyheadcrab

    Bump because I changed the title. I've done more testing and still have no solved this problem. I really need some more ideas.

    Also, I suspect the problem is some weird thing I'm doing in PluginIO.java. The error shows up when I try to make a new instance of the class, even though PluginIO does have a constructor.
     
  8. Offline

    zecheesy

    how do you change the title? edit does not work :eek:
     
  9. Offline

    acuddlyheadcrab

    Go to the thread tools part at the top right corner of your first post :)

    You may not realize it, but I want to smash my computer with a hammer for being so difficult. I've already re-written this fairly large plugin once...

    (AKA. Still need help)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  10. Offline

    Sorroko

    Well according to your error and stack trace line 23 is the plugin description, maybe try this.getDescription()? If it is your pluginIO class, (thinking wildly) is the method public?
     
  11. Offline

    acuddlyheadcrab

    ryan7745 Thanks for the help! But i managed to fix it (thank god) You can see the top post for info :)
     
Thread Status:
Not open for further replies.

Share This Page