Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Not getting nullpointer's stack trace on console (java code)
Not getting nullpointer's stack trace on console (java code) [message #987595] Tue, 27 November 2012 09:53 Go to next message
Antti Rumpunen is currently offline Antti RumpunenFriend
Messages: 5
Registered: November 2012
Junior Member
Hi,
I have an annoying problem: Eclipse doesn't print stacktrack to the console if there is a nullpointer exception. However, I do get stacktrace if some other exception happens... And used to have nullpointer exceptions on the console before. I have no idea why I don't get them anymore.

When a nullpointer occurs Eclipse stops executing the thread (in debug-tab's thread listing) at EventDispatchTread.run() -methods third last line (line 156). On that line there is only }.

Unfortunately I can't provide a screenshot...

I'm using Indigo Service Release 2 and coding with java 6.
Re: Not getting nullpointer's stack trace on console (java code) [message #988247 is a reply to message #987595] Thu, 29 November 2012 06:01 Go to previous messageGo to next message
Antti Rumpunen is currently offline Antti RumpunenFriend
Messages: 5
Registered: November 2012
Junior Member
Over 500 views and no one has experienced the same?
Re: Not getting nullpointer's stack trace on console (java code) [message #988251 is a reply to message #987595] Thu, 29 November 2012 06:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Antti,

You've not even shown any code. It might well be the case that a null
pointer is caught and ignored, but without context

On 27/11/2012 2:03 PM, Antti Rumpunen wrote:
> Hi,
> I have an annoying problem: Eclipse doesn't print stacktrack to the
> console if there is a nullpointer exception. However, I do get
> stacktrace if some other exception happens... And used to have
> nullpointer exceptions on the console before. I have no idea why I
> don't get them anymore.
>
> When a nullpointer occurs Eclipse stops executing the thread (in
> debug-tab's thread listing) at EventDispatchTread.run() -methods third
> last line (line 156). On that line there is only }.
So your question is about java.awt.EventDispatchThread.run()? You can
set a NullPointerException breakpoint (in the Breakpoints view) and see
how that exception is propagated and whether anything on the call stack
will catch it and dump it.
>
> Unfortunately I can't provide a screenshot...
>
> I'm using Indigo Service Release 2 and coding with java 6.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Not getting nullpointer's stack trace on console (java code) [message #988254 is a reply to message #988251] Thu, 29 November 2012 06:39 Go to previous messageGo to next message
Extreme Java is currently offline Extreme JavaFriend
Messages: 6
Registered: November 2012
Junior Member
yes your code seems to engulf the exception. show us the code (may be partial if it is too sensitive)

Re: Not getting nullpointer's stack trace on console (java code) [message #988297 is a reply to message #988254] Thu, 29 November 2012 10:13 Go to previous messageGo to next message
Antti Rumpunen is currently offline Antti RumpunenFriend
Messages: 5
Registered: November 2012
Junior Member
I tested with a simple code (Integer i = null; if(i>0)) which will cause a nullpointer every time I press a button. The code is executed twice by the same thread every time I press the button. Sometimes I get two nullpointer stack traces on the console (without Eclipse stopping the AWT-EventQueue-0 thread) and sometimes I get only one stack trace on the console and Eclipse stopping the AWT-EventQueue-0 thread.

Here is what Eclipse shows me...
Thread...
Thread...
Thread [AWT-EventQueue-0] (Suspended (exception NullPointerException))
EventDispatchThread.run() line:156 [local variables unavailable]
Thread...
Thread...

I can't provide the real code because there is thousands of lines of code and I have no idea where the nullpointer comes from. I debugged what the thread (AWT-EventQueue-0) is doing after I press the button (not my test button). The whole execution goes well. But once the thread starts to do something else (no idea what) I get the nullpointer (with Eclipse stopping the thread every time)...

[Updated on: Thu, 29 November 2012 10:14]

Report message to a moderator

Re: Not getting nullpointer's stack trace on console (java code) [message #988298 is a reply to message #988297] Thu, 29 November 2012 10:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Have you set a NullPointerException breakpoint to figure out where it's
happening?

On 29/11/2012 11:13 AM, Antti Rumpunen wrote:
> I tested with a simple code (Integer i = null; if(i>0)) which will
> cause a nullpointer every time I press a button. The code is executed
> twice by the same thread every time I press the button. Sometimes I
> get two nullpointer stack traces on the console (without Eclipse
> stopping the AWT-EventQueue-0 thread) and sometimes I get only one
> stack trace on the console and Eclipse stopping the AWT-EventQueue-0
> thread.
>
> Here is what Eclipse shows me...
> Thread...
> Thread...
> Thread [AWT-EventQueue-0] (Suspended (exception NullPointerException))
> EventDispatchThread.run() line:156 [local variables unavailable]
> Thread...
> Thread...
>
> I can't provide the real code because there is thousands of lines of
> code and I have no idea where the nullpointer comes from. I debugged
> what the thread (AWT-EventQueue-0) is doing after I press the button.
> The whole execution goes well. But once the thread starts to do
> something else (no idea what) I get the nullpointer (with Eclipse
> stopping the thread every time)...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Not getting nullpointer's stack trace on console (java code) [message #988313 is a reply to message #988298] Thu, 29 November 2012 11:22 Go to previous messageGo to next message
Antti Rumpunen is currently offline Antti RumpunenFriend
Messages: 5
Registered: November 2012
Junior Member
Thanks Ed for replying,
I assume have access to EventDispatchThread so you can see the lines... I added a breakpoint to EventDispatchThread.run() -method's line 153. It steps from 153 to 155 and then it steps to 156 (which is the end of synchronized-block). After that when I take the next step I get NullPointerException. Does it mean that theQueue -object is null or what? At least it doesn't seem to be null in Eclipse's Variables-tab.
Re: Not getting nullpointer's stack trace on console (java code) [message #988317 is a reply to message #988313] Thu, 29 November 2012 11:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Antti,

It sounds like you've not set a NullPointerException breakpoint which
you can do in the Breakpoint view via that little icon that looks like
J! so please try that to answer the question yourself.

On 29/11/2012 12:22 PM, Antti Rumpunen wrote:
> Thanks Ed for replying, I assume have access to EventDispatchThread so
> you can see the lines... I added a breakpoint to
> EventDispatchThread.run() -method's line 153. It steps from 153 to 155
> and then it steps to 156 (which is the end of synchronized-block).
> After that when I take the next step I get NullPointerException. Does
> it mean that theQueue -object is null or what? At least it doesn't
> seem to be null in Eclipse's Variables-tab.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Not getting nullpointer's stack trace on console (java code) [message #988325 is a reply to message #988317] Thu, 29 November 2012 12:06 Go to previous messageGo to next message
Antti Rumpunen is currently offline Antti RumpunenFriend
Messages: 5
Registered: November 2012
Junior Member
Hehheh, didn't know that you could set that kind of breakpoints... Problem solved. Thanks Ed!

There was the following piece of code in which window was null. No idea why the focus is set like that (not my code). And the reason why Eclipse doesn't show stacktrace to that line is probably something that needs more indepth understanding about threads etc.
EventQueue.invokeLater(new Runnable()
{
  public void run()
  {
    window.setFocus();
  }
});
Re: Not getting nullpointer's stack trace on console (java code) [message #1621418 is a reply to message #988325] Tue, 17 February 2015 22:05 Go to previous message
Vishal Kumar is currently offline Vishal KumarFriend
Messages: 1
Registered: February 2015
Junior Member
Hello Guys,

I found this error coming at runtime in my Swing code. I hadn't handled an exception and hence this was not working and was showing the Dispatch Thread message.

I accept the error display is not explanatory in this case.

Cheers,
Vishal Kumar
Previous Topic:Jetty SSL Exception : Connection was aborted
Next Topic:How to extract class hierarchy/call graph relationships from java sources?
Goto Forum:
  


Current Time: Tue Apr 16 22:25:30 GMT 2024

Powered by FUDForum. Page generated in 1.08146 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top