Solved Invalid Plugin Error: NoClassDefFoundError

Discussion in 'Plugin Development' started by rj3824, Feb 20, 2017.

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

    rj3824

    So i always get this error when I try to load my plugin:

    Code:
    Could not load 'plugins\DeathMatch.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: net/minecraft/server/v1_11_R1/World
      at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:298) [spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:203) [spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:535) [spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/v1_11_R1/World
      at java.lang.Class.forName0(Native Method) ~[?:1.8.0_121]
      at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_121]
      at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      ... 6 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_11_R1.World
      at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:91) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_121]
      at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_121]
      at java.lang.Class.forName0(Native Method) ~[?:1.8.0_121]
      at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_121]
      at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot-1.10.2.jar:git-Spigot-047f737-744e1a1]
      ... 6 more

    I'm not sure why but I know that it is because of this code:

    MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();WorldServer worldServer = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();npc = new EntityPlayer(minecraftServer, worldServer, new GameProfile(UUID.randomUUID(), "SHOP"), new PlayerInteractManager(worldServer));

    Anyone willing to share some wisdom?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @rj3824 Make sure that the version you are building on and the version that you are running with are the same.
     
  3. Offline

    dNiym

    Check your imports where you found this code, importing minecraft server is version specific.

    Meaning it will be something like
    import net.minecraft.server.v1_11_R1.MinecraftServer

    This means the code referencing that is version specific, i.e. If it's for v1.8.3 that's the version of bukkit you need to be running.

    You can change that to a newer version but it's likely methods or variable names have changed as they do from version to version. And it will require some reworking of your version specific (NMS) code to get working again.




    Sent from my iPhone using Tapatalk
     
  4. Offline

    rj3824

    I have checked that, this code is part of a very big plugin that works without that code so it's nothing to do with that.
     
  5. Offline

    timtower Administrator Administrator Moderator

    You are building on 1.11 craftbukkit, your server is running 1.10.
    That is why you are getting the errors. NMS does this.
     
    Last edited: Feb 22, 2017
  6. Offline

    dNiym

    Part of the plugin may very well work but whatever part of this code relies on the NMS code is most definitely broken! What happens is when a new version of minecraft server is released a lot of things change in the source code, variable names, methods etc when you try to run a newer or older version it does not know how to access the same methods / variables because the names have changed.


    Sent from my iPhone using Tapatalk
     
  7. Offline

    rj3824

    Thanks so much, had to switch to 1.10.2 craftbukkit in my Pom.xml file to match my 1.10.2 server and it's working perfectly, thanks!
     
    Last edited by a moderator: Feb 22, 2017
Thread Status:
Not open for further replies.

Share This Page