randalthor 6 Share Posted September 10, 2015 http://pastebin.com/SLQCjuZv I'm getting a null pointer exception thrown on line 22. I tried everything I know to debug it myself. On line 5 I checked if "a" was null. In the two statements before I added code which proved both ctx.getMap() != null and ctx.getMap().isVisible(Tile) != null the output for both the cases on line 20 and 17 was printed to the console. I'm still at a loss as to why: if(ctx.getMap().isVisible(a.getNearestTile(ctx.getLocalPlayer()))) { is throwing a null pointer exception edit: I also just did another check to see if ctx.getLocalPlayer() != null and it passed. Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted September 10, 2015 Utilize breakpoints. Link to comment Share on other sites More sharing options...
randalthor 6 Author Share Posted September 11, 2015 Utilize breakpoints. what? How? Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted September 11, 2015 what? How? Google "Using breakpoints with x" and in place of "x" type your IDE's name. Link to comment Share on other sites More sharing options...
Nuclear Nezz 2012 Share Posted September 11, 2015 could you give the stacktrace as well Link to comment Share on other sites More sharing options...
randalthor 6 Author Share Posted September 12, 2015 I remember seeing a topic on the forums about running the scripts using the command prompt. I am able to run dreambot using /path/to/client.jar however once that is open and I try /path/to/dreambot local scripts/scriptname.jar nothing happens. I understand this doesn't work because you have to run the script through the dreambot client but don't know the commands to do that. Here is the stacktrace: [ERROR]17:47:16: Exception has occurred while running! Please report error to developer if problem persists: java.lang.NullPointerException at org.dreambot.api.methods.map.Map.isVisible(Map.java:59) at rand.dreambot.RandsAPIMethods.walking(RandsAPIMethods.java:241) at rand.dreambot.jewelryMaker.MainJewleryMaker.onLoop(MainJewleryMaker.java:165) at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:223) at java.lang.Thread.run(Thread.java:745) http://pastebin.com/cFTs2sL8 The error at line: RandsAPIMethods.java:241 is from line 18 in the paste. This shouldn't happen because of the checks on line 5, 16, and 17. I don't have access to the API code so I can't tell what is happening at line 59 in the Map class where the null pointer exception originates. I'm pretty sure I used the API correctly with the following code: if(ctx.getMap().isVisible(a.getNearestTile(ctx.getLocalPlayer()))) { without more information I assume the problem originates from the API? Can anyone confirm? Is it worth it to still use breakpoints. From what I read online they are useful to step through your program and find what line the problem originates at. However, the stack trace did the same thing pointing out the origin of the problem as line 59 in the Map class. Google "Using breakpoints with x" and in place of "x" type your IDE's name. Is it worth it to still use breakpoints? From what I read online they are useful to step through your program and find what line the problem originates at. However, the stack trace did the same thing pointing out the origin of the problem as line 59 in the Map class. Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted September 12, 2015 Is it worth it to still use breakpoints? From what I read online they are useful to step through your program and find what line the problem originates at. However, the stack trace did the same thing pointing out the origin of the problem as line 59 in the Map class. The whole point to using a debugger is to analyze the runtime environment at a specific execution state. You will be able to look at all your local variables and check their values/pointers. If one that you're using has a null pointer, well, therein lies the cause of the exception. Link to comment Share on other sites More sharing options...
randalthor 6 Author Share Posted September 12, 2015 The whole point to using a debugger is to analyze the runtime environment at a specific execution state. You will be able to look at all your local variables and check their values/pointers. If one that you're using has a null pointer, well, therein lies the cause of the exception. Ok so I think I found where the null pointer is occuring by using breakpoints. However, I don't think it is a problem that I can solve. Here all my variables are not null: Here is the line that the stack trace shows the exception being thrown at: My best guess is this point object created at -1,-1 may cause the future null pointer exception: First time I see a null object: Probable cause of the null pointer exception: Other null objects: could you give the stacktrace as well BTW. Nezz Here is the stacktrace I already posted above. [ERROR]17:47:16: Exception has occurred while running! Please report error to developer if problem persists: java.lang.NullPointerException at org.dreambot.api.methods.map.Map.isVisible(Map.java:59) at rand.dreambot.RandsAPIMethods.walking(RandsAPIMethods.java:241) at rand.dreambot.jewelryMaker.MainJewleryMaker.onLoop(MainJewleryMaker.java:165) at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:223) at java.lang.Thread.run(Thread.java:745) I think I found the null pointer exception cause at line 393 of the field class that dreambot uses for Maps.isVisible() http://i.imgur.com/62Rar7j.png No idea how to solve this problem myself though. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.