How to read Exceptions in the console.

Discussion in 'Plugin Development' started by Gabriel333, Aug 1, 2011.

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

    Gabriel333

    I have just started to learn Java and have made my first plugin "BukkitContribCommands" for CraftBukkit. I have used alot of toturials on Bukkit.org, Youtube but I have not found a guide how to read the Exceptions in the console. Could anyone help me to understand how to read the error. Where can I find some stuff to read about this? Im using Eclipse, Git and Github.
    https://github.com/Gabriel333/BukkitContribCommands


    The Error is: ClassNotFoundException
    and I found a little help here:
    http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ClassNotFoundException.html

    How do I know which *.java file the error is in and where in the file is the error????

    This is the output in my console:
    --------------------------------------------------------------------------------------
    Show Spoiler
    Code:
    151 recipes
    16 achievements
    11:56:31 [INFO] Starting minecraft server version Beta 1.7.3
    11:56:31 [INFO] Loading properties
    11:56:31 [INFO] Starting Minecraft server on *:25565
    11:56:31 [WARNING] **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    11:56:31 [WARNING] The server will make no attempt to authenticate usernames. Be
    ware.
    11:56:31 [WARNING] While this makes the game possible to play without internet a
    ccess, it also opens up the ability for hackers to connect with any username the
    y choose.
    11:56:31 [WARNING] To change this, set "online-mode" to "true" in the server.set
    tings file.
    11:56:31 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-945-
    g73697a4-b1000jnks (MC: 1.7.3)
    11:56:31 [SEVERE] Could not load 'plugins\BukkitContribCommands.jar' in folder '
    plugins':
    java.lang.ClassNotFoundException: me.gabriel333.BukkitContribCommands.BukkitCont
    ribCommands
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:36)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:24)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:247)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:168)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:207)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:130)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:128)
            at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:97)
            at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigur
    ationManager.java:51)
            at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:132)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    11:56:31 [INFO] [SuperpermBridge] Superperm/Permissions bridge initialized
    11:56:31 [INFO] Preparing level "world"
    11:56:31 [INFO] Preparing start region for level 0 (Seed: 6078615818307207179)
    11:56:32 [INFO] Preparing spawn area: 40%
    11:56:33 [INFO] Preparing start region for level 1 (Seed: -4410407307351421114)
    11:56:34 [INFO] Preparing spawn area: 0%
    11:56:35 [INFO] Preparing spawn area: 52%
    11:56:36 [INFO] BukkitContrib 0.1.7 has been initialized
    11:56:36 [INFO] PermissionsBukkit v1.1 is now enabled
    11:56:36 [INFO] [SuperpermBridge] Superperm/Permissions bridge enabled
    11:56:36 [INFO] Server permissions file permissions.yml is empty, ignoring it
    11:56:36 [INFO] Done (0,459s)! For help, type "help" or "?"
    >[/SPOILER]
     
  2. Offline

    Shamebot

    How does your jar look like?
     
  3. Offline

    Gabriel333

    I have uploaded the jar to:
    http://dl.dropbox.com/u/36067670/BukkitContribCommands/BukkitContribCommands.jar
    And source to:
    http://dl.dropbox.com/u/36067670/BukkitContribCommands/BukkitContribCommand.zip

    I want to learn to debug the Javacode myself :) (not you to find the error - allthough a little help would be nice, if just I understand how you find the error :) I dont want to ask everytime I make an error in my code :'(.

    The error is:
    Show Spoiler
    Code:
    16:28:45 [SEVERE] Could not load 'plugins\BukkitContribCommands.jar' in folder '
    plugins':
    java.lang.ClassNotFoundException: me.gabriel333.BukkitContribCommands.BukkitCont
    ribCommands
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:36)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:24)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:247)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:168)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:207)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:130)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:128)
            at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:97)
            at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigur
    ationManager.java:51)
            at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:132)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)[/SPOILER]
     
  4. Offline

    Coryf88

    Alright, here's a hint to solving the problem.

    Double check your plugin.yml and your package.
     
  5. Offline

    Gabriel333

    Okay :) I found it. I should have remembered that I renamed my package acouple of times today because I read a bukkit naming convention which told us not to use org.bukkit.gabriel333..... (which I did previously).

    Now I got a little further and got to the next error. Its a NoSuchMehtodException, I will try to dig into that myselv, before asking of help. I also have to look into this debuging guide :
    http://forums.bukkit.org/threads/debugging-plugins-in-eclipse.4043/

    Thank you for you help so far :)


    ---------------------------------------------------------------------------------------------------------------------------
    Show Spoiler
    Code:
    16:54:11 [SEVERE] Could not load 'plugins\BukkitContribCommands.jar' in folder '
    plugins':
    java.lang.NoSuchMethodException: dk.gabriel333.BukkitContribCommands.BukkitContr
    ibCommands.<init>()
            at java.lang.Class.getConstructor0(Class.java:2706)
            at java.lang.Class.getConstructor(Class.java:1657)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:171)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:207)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:130)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:128)
            at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:97)
            at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigur
    ationManager.java:51)
            at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:132)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    [/SPOILER]
     
  6. To help you understand the actual exception (EDIT: refering to the first one you posted):
    The exception you got there wasn't thrown by any of your code, but by the "plugin loader" of bukkit - because it was unable to find the main-class of your plugin.
    This is why you don't find any of your classes or *.java-files listed there. Usually, when there is a NullPointerException or similar in your code, the stack trace (that's all that bunch of crap that is showing up) looks somewhat like that:

    Show Spoiler
    Code:
    2011-06-25 21:31:48 [SEVERE] Could not pass event ENTITY_DEATH to DeathControl
    java.lang.NullPointerException
        at bone008.bukkit.DeathControl.DeathManager.handle(DeathManager.java:85)
        at bone008.bukkit.DeathControl.DeathControlEntityListener.onEntityDeath(DeathControlEntityListener.java:34)
        at org.bukkit.plugin.java.JavaPluginLoader$56.execute(JavaPluginLoader.java:635)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:310)
        at net.minecraft.server.EntityPlayer.a(EntityPlayer.java:146)
        at net.minecraft.server.EntityLiving.damageEntity(EntityLiving.java:403)
        at net.minecraft.server.EntityHuman.damageEntity(EntityHuman.java:441)
        at net.minecraft.server.EntityPlayer.damageEntity(EntityPlayer.java:184)
        at net.minecraft.server.EntityLiving.a(EntityLiving.java:506)
        at net.minecraft.server.EntityHuman.a(EntityHuman.java:876)
        at net.minecraft.server.Entity.a(Entity.java:656)
        at net.minecraft.server.EntityPlayer.b(EntityPlayer.java:360)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:368)
        at net.minecraft.server.Packet10Flying.a(SourceFile:126)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:223)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:75)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)


    The first line comes from bukkit and indicates that the exception was thrown in the ENTITY_DEATH-event by the plugin "DeathControl" (that's what I found in my server log while I was fixing bugs in it, btw ;)).

    Below it says which type of exception was thrown (java.lang.NullPointerException).
    Then there is a trace of where the exception was passed through, until the point where it was caught (the lowest line). Interesting for you should only be the first lines.

    In this case, the exception was caused by the class "bone008.bukki.DeathControl.DeathManager" in the method "handle". And it in DeathManager.java at line 85.

    If the top line of your trace isn't one of your classes, it is likely that you passed something invalid into a bukkit-method. Then you just go down until you find something of yours that appears logical.


    I hope that generally helped you ;)
     
  7. Offline

    Gabriel333

    It did! SO if I understand you right (looking at the new error) I properly now have an error where i try to call a non-existing method i my main class BukkitContribCommands.java . :)
     
  8. Offline

    Coryf88

    Close, but not quite. It's not you calling the method.

    -----

    You will most likely have trouble figuring out the cause and what to do to fix it. So, if you end up not being able to figure it out, expand the spoiler.

    Show Spoiler
    Hint 1: A class constructor.
    Show Spoiler
    Hint 2: BukkitContribCommands's constructor. (Note: Next spoiler is the solution)
    Show Spoiler
    Solution: Remove BukkitContribCommands's constructor.
     
  9. Offline

    Gabriel333


    Thank you VERY much!!! I had to use the solution. Im not that good with this yet :( but I learn fast! My plugin runs now, with a set of 6 "test" commands - all using permissions3 or permissionsbukkit if detected, and my configfile loaded from the jarfile or from filesystem if its exists :)
     
Thread Status:
Not open for further replies.

Share This Page