NullPointerException after Update CB

Discussion in 'Plugin Development' started by edocsyl, May 18, 2012.

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

    edocsyl

    Hi, i just updated my Bukkit Test Server, after this i got a Error with my plugin.
    I Don't know whats wrong.. Any Ideas?

    Code:
    2012-05-18 18:44:40 [SEVERE] Error occurred while enabling CraftingTerritory.net by Edocsyl.ch v0.6.3 (Is it up to date?)
    java.lang.NullPointerException
        at ch.edocsyl.CraftingTerritory.CraftingTerritory.onEnable(CraftingTerritory.java:65)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:215)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:336)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:256)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:238)
        at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:372)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:359)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:188)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:423)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    
    Greez Edocsyl
     
  2. Offline

    Father Of Time

    A stack trace is useless without source code to compare it against.

    Also, I don't believe this is the full stack as I don't see a "caused by:" declaration.

    Provide the necessary information to debug your issue, then we may be able to assist you.
     
  3. Offline

    edocsyl

  4. Offline

    Father Of Time

    Edocsyl, you need to narrow down the code provided to the trouble area. I mean this politely as possible, but I am not going to waste time digging through an entire project looking for a NPE without knowing the class, the line... anything...

    cause the crash again, copy the entire stack trace (if it's a NPE it will say "caused by" and give a line number and a class name), then copy and paste the function that is throwing the NPE into this post.

    I can most easily help you if you provide me nothing more than the entire stack trace and a single function (or body of code) that is causing the NPE.
     
  5. Offline

    edocsyl

    Father Of Time This is my problem.. There is no "caused by". I cud fix this too if i know where the problem is.. But there is no "caused by".

    Oke. I commented out the CommandExecutor. Now there is no error.

    Is in the following code something wrong?

    Code:
     
            mycExecutor = new GSMCommandExecutor(this);
            getCommand("grundstueck").setExecutor(mycExecutor);
            getCommand("neuespasswort").setExecutor(mycExecutor);
            getCommand("registrieren").setExecutor(mycExecutor);
            getCommand("tool").setExecutor(mycExecutor);
            getCommand("ticket").setExecutor(mycExecutor);
            getCommand("test").setExecutor(mycExecutor);
    
    Maby there is something new with the CommandExecutor in the 1.2.5-R2.0

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

    Father Of Time

    If there is no "caused by" line in the stack (which is very odd, I've never seen that in Java for a NPE to date) then your only other solution that I am aware of is line printing. To do this:

    in between EVERY SINGLE line of code place the following:

    Code:
    log.info("Reached 1");
    //code line 1
    log.info("Reached 2");
    //code line 2
    log.info("Reached 3");
    //code line 3
    log.info("Reached 4");
    etc.
    As you compile the assembler will hault at the line the NPE occured, meaning if your console prints out the following:

    Then you know it was the line of code that is between print statement 2 and print statement 3 that is causing the crash. This method is time consuming and just plain annoying, but in my 15+ years of programming I have never once been unable to locate an NPE utilizing this method.

    This is my "nothing else makes sense", last ditch effort approach, but it works... Give this a shot and see if you can locate your issue.
     
  7. Offline

    Double0negative

    Cause by Is not in all stack traces. the caused by in a stack trace means that there was a chain of exceptions that caused another exception to be thrown. (eg. a command has an exception and caused the command handler to throw an exception, the reason why OnCommand exceptions have caused by). Take a look at this (http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Throwable.html) " Finally, it can contain a cause: another throwable that caused this throwable to get thrown."

    They also show the exact line and class of where the exception happened. This one happened in the class CraftingTerritory on line 65

    My guess from this error, since none of the other setExecuter methods NPE out that the command tool dosent exist (although im not sure if this would throw a NPE or not). Try doing what FOT said and printing between each line
     
  8. Offline

    edocsyl

    @Father Of Time
    This method with "log.info("Reached 1");" is quite good. I figured out, that the
    getCommand("tool").setExecutor(mycExecutor);
    makes problem.

    Now i replaced the tool command with tool2 and the error is missing.

    Maby there is a problem with a other plugin who uses the /tool command ?


    Is WorldEdit using this command ? I removed it from the plugin folder. Now there is no error.
     
  9. Offline

    Father Of Time

    Thank you for explaining this in greater detail, your comments were far more beneficial to the original poster than mine were, I simply didn't have enough time to explain the issue properly.


    I would guess this to be extremely possible. The command /tool is a very generic command, I can only imagine that another public plug-in has attempted to use it. Try using a thesaurus to find another word with the same meaning, but not as regularly used; for instance, I am making a "displaycase" plug-in for my server because I don't like any of the existing projects, and to avoid naming conflicts I chose to call it "Plinth" which means "pedestal on which objects are set upon", yet is rarely socially used, so it's more than likely there will never be a command name conflict.

    Try changing the name to something less generic and I would imagine your problem will go away, good luck with the remainder of your project!
     
  10. Offline

    edocsyl

    Sry for the waist of time for this issue.
    This Project is not public, ist just for a buddy who makes a server.
    Its also my first bigger Project.
    Thanks for the good suggestions and advices and sorry for my bad english.
     
Thread Status:
Not open for further replies.

Share This Page