Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • finding cause of null pointer exception


    randalthor

    Recommended Posts

    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

    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

    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

    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:

     

     

    tUOczq4.png

     

     

    Here is the line that the stack trace shows the exception being thrown at:

     

     

    8wQVh6e.png

     

     

    My best guess is this point object created at -1,-1 may cause the future null pointer exception:

     

     

    5vTQ2oh.png

     

     

    First time I see a null object: 

     

     

    jieyO15.png

     

     

    Probable cause of the null pointer exception:

     

     

    62Rar7j.png

     

     

    Other null objects:

     

     

    6xIphBf.png

    OqaNu5B.png

     

     

     

     

    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()

     

     

    No idea how to solve this problem myself though.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.