Results 1 to 6 of 6
  1. #1
    mallorz is offline Member
    Join Date
    Jan 2014
    Posts
    84
    Rep Power
    0

    Default Does this mean anything? Decifering Exceptions

    I am struggling with my current Java assignment and can't figure out how to use the debugger to step though a GUI application to see what exactly is happening where.

    When I populate all fields in my GUI and they are validated successfully, the end message does not appear. Instead, in the console window, I get the following exception pointing to my printInvoice() method indicating a NullPointerException.

    As I said, everything has been filled out correctly and this program at least mostly-operated yesterday morning. Is there a way to find out where this is coming from using the message below? I suspect it is stemming from the date fields I added and will look into that but I am still curious. I would guess not but maybe someone out there can offer me some advice and/or tell me how (if) the debugger tool can be used.

    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at edu.witc.Ch_08_10ex2.controller.Hotel_Processor.printInvoice(Hotel_Processor.java:219)
    	at edu.witc.Ch_08_10ex2.controller.Hotel_Processor$SubmitButtonListener.actionPerformed(Hotel_Processor.java:61)
    	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    	at java.awt.Component.processMouseEvent(Unknown Source)
    	at javax.swing.JComponent.processMouseEvent(Unknown Source)
    	at java.awt.Component.processEvent(Unknown Source)
    	at java.awt.Container.processEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Window.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$200(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    P.S. Yup! It's from the date - just commented out the fields. But seriously, this debugger thing?
    Last edited by mallorz; 02-21-2014 at 05:26 PM.

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,157
    Rep Power
    6

    Default Re: Does this mean anything? Decifering Exceptions

    to be honest, I find using a debugger to debug a Swing application pretty hairy because it involves multithreading. I'd try to find problems by sprinkling System.out statements first if I were you.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,004
    Rep Power
    3

    Default Re: Does this mean anything? Decifering Exceptions

    One other thing you can do, that is *if* you use a decent IDE like JetBrains IntelliJ IDEA, is to set Exception breakpoints. In IDEA you can set a breakpoint to stop your program on certain conditions, like the occurance of a NPE, AIOOBE and what have you.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default Re: Does this mean anything? Decifering Exceptions

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at edu.witc.Ch_08_10ex2.controller.Hotel_Processor.pr intInvoice(Hotel_Processor.java:219)
    There is a variable with a null value on line 219. Look at line 219 in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
    If you can not tell which variable it is, add a println just before line 219 and print out the values of all the variables on that line.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    mallorz is offline Member
    Join Date
    Jan 2014
    Posts
    84
    Rep Power
    0

    Default Re: Does this mean anything? Decifering Exceptions

    I managed to get the debugger to work. The issue seems to lie in my customer class - everything was null. I was messing around yesterday and I guess I forgot to change a few things back there. Thanks guys.

    I believe that ultimately leaves me with one more issue to overcome and then I can have this thing over with! :)
    Last edited by mallorz; 02-21-2014 at 06:19 PM.

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,157
    Rep Power
    6

    Default Re: Does this mean anything? Decifering Exceptions

    Quote Originally Posted by SurfMan View Post
    One other thing you can do, that is *if* you use a decent IDE like JetBrains IntelliJ IDEA, is to set Exception breakpoints. In IDEA you can set a breakpoint to stop your program on certain conditions, like the occurance of a NPE, AIOOBE and what have you.
    Hm, that's very interesting. Although you can basically do that in any IDE by setting a breakpoint in a specific method of the Exception you want to trap. I've seen a colleague do that without even having the source code.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. exceptions
    By ii88xix88ii in forum JCreator
    Replies: 6
    Last Post: 03-12-2013, 04:07 PM
  2. help with exceptions
    By dawnMist in forum New To Java
    Replies: 31
    Last Post: 11-15-2012, 11:09 AM
  3. Exceptions
    By Nerijus in forum New To Java
    Replies: 8
    Last Post: 05-18-2010, 02:44 PM
  4. Exceptions
    By hedonist in forum New To Java
    Replies: 10
    Last Post: 09-08-2009, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •