Development Assistance Debugging null-pointers

Discussion in 'Plugin Help/Development/Requests' started by ShadowDisruptor, Feb 28, 2015.

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

    ShadowDisruptor

    I've been getting a null pointer in my plugin. It says the error is in 3 classes (Where they call each other) I reviewed each class and printed out all the variables before the line I get the error on. None of the variables were null and I can't seem to find out where the heck this nullpointer is coming from. Are there any other things that throw this error or any other ways to debug it? Any help is appreciated.
     
  2. Offline

    adam753

    @ShadowDisruptor
    Generally speaking, NullPointerException is the easiest common exception to debug. The top* line in your stack trace will be the actual point at which the error happened, the other lines below that will tell you the order of method calls which led to that point (hence why it's called a stack trace.) Go ahead and post your code if you'd like me to look at it.

    (* unless your console reads bottom-to-top)
     
  3. Offline

    ShadowDisruptor

    Yeah, that's where I checked the most. I can't seem to find where the error is. I might be completely blind and missing something, but I check every single variable.
     
  4. Offline

    adam753

    @ShadowDisruptor
    Really can't help you unless you post your code, at least the line the error is coming from.
     
  5. Offline

    Konato_K

  6. Offline

    ShadowDisruptor

  7. Offline

    teej107

    What's so hard to find in a NPE? The stacktrace tells you exactly where the NPE occurred.
     
  8. Offline

    ShadowDisruptor

    Here is the class causing trouble.
    Here is the stacktrace:
    Show Spoiler

    28.02 18:11:57 [Server] INFO ... 13 more 28.02 18:11:57 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_72] 28.02 18:11:57 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_72] 28.02 18:11:57 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_72] 28.02 18:11:57 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_72] 28.02 18:11:57 [Server] INFO at listeners.BuildingBuyInventory.onInventoryClick(BuildingBuyInventory.java:67) ~[?:?] 28.02 18:11:57 [Server] INFO at buildings.BuildingCreator.createBuilding(BuildingCreator.java:101) ~[?:?] 28.02 18:11:57 [Server] INFO at buildings.Building.spawn(Building.java:84) ~[?:?] 28.02 18:11:57 [Server] INFO Caused by: java.lang.NullPointerException 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.PacketPlayInWindowClick.handle(PacketPlayInWindowClick.java:65) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:15) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:1477) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigotRSNAPSHOT.jar:git-Spigot-1649] 28.02 18:11:57 [Server] INFO org.bukkit.event.EventException
     
  9. Offline

    teej107

  10. Offline

    ShadowDisruptor

    If you read the post, you would know.
     
  11. Offline

    teej107

  12. Offline

    ShadowDisruptor

    Purpose of thread being moved to requests? It isn't a plugin request.

    If you don't have a good reason to comment, please don't. In my thread, I already stated I checked every line given and the values inside. None returned null, and I saw no errors. Instead of spamming the link to the how to debug forum, either be constructive and actually help or please don't comment at all. I came here for help, not useless links to threads I have already read.
     
    Last edited by a moderator: Feb 28, 2015
  13. Offline

    teej107

    If that link is "useless" to you, then you should read it until you understand it so it becomes useful. Reading stacktraces is something that developers should know how to do. The least you could do is point out what line (not plural) the NPE is occurring.
     
  14. Offline

    ShadowDisruptor

    It's useless because I already know how to read the stacktrace! I know the line and I know the error, I just have been unable to figure out what exactly is null. It is line 67 in the provided class, but I provided the stack trace as well. So much for flaming about reading stack traces..
     
  15. Offline

    teej107

    I wasn't flaming. I was suggesting. If you knew how to read stacktraces correctly, you would know that the error is not at line 67. It's at:
    Code:
    buildings.Building.spawn(Building.java:84)
     
  16. Offline

    ShadowDisruptor

    After re-looking at @adam753 's post, the direction of the console is what messed be up. I'm using a new server provider, and the console goes the opposite way than I'm used to. Thanks for the help.
     
Thread Status:
Not open for further replies.

Share This Page