Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

How to read and interpret a Java stack trace

Interesting...
Loyal Member
Joined
Oct 25, 2008
Messages
1,372
Reaction score
604
I've seen too many help threads with people posting pictures of their errors without checking where the error might be, so I thought this quick and simple tutorial should help those who need it.

So what's a stack trace?
To not get too technical, it is simply the list of methods that your (in this case) server called before the exception (aka error) was thrown. That giant wall of text that people usually don't bother to read is actually super useful information.

This quick tutorial will serve to show you where your error is. It will NOT be showing you how to fix them, partly because it depends on so many different factors. However, finding out what file and line is causing your error should vastly improve your chances of being able to fix them.

Below are five pictures of random .bat files I found by searching through the help section.











Don't panic. It's not as bad as it looks. Let's break it down one by one.



So this fellow here has himself a NullPointerException. A classic. :blush:

If you look at the stack trace you'll get (in this case), your 3 methods.

  • main inside ChannelServer.java on line 445
  • run inside ChannelServer.java on line 227
  • init inside EventScriptManager on line 72

So you're probably thinking, what gives? Where is the error? Are you Ducking with me? The answer is all three. Going from bottom to top gives you order in which they were called, and so the error was caused directly by the top-most line, and indirectly by the one's below it.

In other words, he needs to go to the method init inside EventScriptManager.java on line 72, and fix it. Once you're given the exact line and file, if you somewhat know what you're doing, you will be able to fix it.

Moving on!



Ahh, the NPE again. Can't escape it :love:.

So let's ignore that SQL issue at the top for the sake of this tutorial. This guy is all fucked up. Let's focus on the thing below. Again you have a NullPointerException. However, this time you can see there are more methods and the stack is bigger.

Why is that you ask? Simple. The error was located deeper in the source. Notice how it goes from Start.java to MapleMonsterInformationProvider.java to MapleDataTool.java? The deeper the error, the bigger the trace. It doesn't mean the process is any harder.

Again, the error would be found directly in getString in MapleDataTool on line 30, and indirectly on the files and lines below it. Fixing the error is whole other issue, however.



So this guy got himself a ClassCastException. The following sentence explains it in more detail.

Follow the same process as before and you should see that the error is in the same file, but different line. Go down to trace to get a bit more context about what the error might be and you will see that since it's using the Skill.java and SkillFactory.java files, your error is skill loading-related.



Here's a ClassNotFoundException.

Super useful to note the mysql://localhost:3306/judoms?autoReconnect=true part. It immediately lets you know this is database-related.

Follow the stack and you see it's during initialization. How do I know? It's in the run method inside Start.java on line 47. Go lower in the trace and you'll see that it was caused by an error loading the database credentials, as evident by the NPE at line 30 in ServerProperties.java. I'm sure the solution would be quite simple.



At last we have another ClassCastException.

I suppose this one is really similar to the one above, but the same deal. Look at the method, what file it's in and what line it's located. If that doesn't give you enough context, go down the stack. Eventually, you will get a sense of what is causing the error and, hopefully, what you could do to fix it.

At the very least, at least you can now provide more detailed help threads if you provide some code located in the vicinity of these errors.

I hope I've turned you into a stack trace reading god and good luck with your future NPEs. :cool:
 

Attachments

You must be registered for see attachments list
Back
Top