Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to see true origin of exception?

 
Libor Jelinek
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!
I am encountering strange behavior - runtime exceptions like IllegalArgumentException etc. and stack trace doesn't contain any reference to my own code. It is only refering to libraries I have used.

But it is absolutely doubtless that source of exception is my application. Is is very difficult to find out where it is originating because it is uncontrolled exceptions inherited from RuntimeException.

Please, is there any way how to see really full stack trace where will be referred line in my application?

Thanks
Libor
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to get the stack trace:
 
Arun Chidam
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If run your application in debug mode you should be able to find out the trace of the exception thrown....
 
Paul Clapham
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally you would "see" a stack trace by writing it to stderr or some other place where you could look at it yourself. Could you provide an example of the strange behaviour you describe?
 
Libor Jelinek
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all replies but it's little misunderstanding. I am experiing RuntimeException exceptions (uncontrolled exceptions that don't have to be catched explicitly).

I can see stack trace but there isn't information about where in my own code (not libraries or environment) exceptions was thrown. Eg. this only what I see (a lot of lines but no with my own code - it's NetBeans Platform app):

java.lang.NullPointerException
at org.openide.windows.OpenComponentAction.actionPerformed(OpenComponentAction.java:89)
at org.openide.awt.AlwaysEnabledAction$1.run(AlwaysEnabledAction.java:137)
at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:95)
at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
at org.openide.awt.AlwaysEnabledAction.actionPerformed(AlwaysEnabledAction.java:140)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6437)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6202)
at java.awt.Container.processEvent(Container.java:2213)
at java.awt.Component.dispatchEventImpl(Component.java:4793)
at java.awt.Container.dispatchEventImpl(Container.java:2271)
at java.awt.Component.dispatchEvent(Component.java:4619)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4816)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4476)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4406)
at java.awt.Container.dispatchEventImpl(Container.java:2257)
at java.awt.Window.dispatchEventImpl(Window.java:2677)
at java.awt.Component.dispatchEvent(Component.java:4619)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:662)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
 
Libor Jelinek
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It other words it means that I have some code causing NullPointerException but I don't know where (no mention about my files in exception stack trace).

I did a tons of changes from last commit. It would be nice to know where is the problem causing RuntimeException. Otherwise I will have to revert changes and start from the last known working revision :-( And I will hope that I will not do same bug once more.

Our app is containg of hundreds of files. From last commit I changes about 200-300 lines of code. Because of these changes something is going wrong - and I don't know why (because it's not in stack trace).

Please do you have any experience with these mystic RuntimeExceptions? With no information where is the true origin?

Libor
 
Paul Clapham
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, it's Swing. That kind of thing usually happens when you have Swing code which isn't running on the Swing event thread. Read the Concurrency in Swing tutorial to see what that's about.
 
Libor Jelinek
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Oh, it's Swing. That kind of thing usually happens when you have Swing code which isn't running on the Swing event thread. Read the Concurrency in Swing tutorial to see what that's about.


Yes, yes it's Swing. But how it is possible that exception stack trace doesn't contain information about origin? How it is theoretically possible? Can I somehow to simulate or hide the exception origin programmatically?
 
Paul Clapham
Sheriff
Pie
Posts: 20756
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception DOES contain information about its origin. However that origin isn't in your code, it's in the Swing code which processes GUI events. And errors in that code generally occur when something in another thread (e.g. your code) has changed some Swing data in a non-thread-safe way. Don't spend your time trying to hide the problem, fix it. Read the tutorial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic