Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
schepurny
Posts: 168
Registered: ‎11-22-2009
My Device: 9000 Bold, 8300 Curve

"no stack trace" in Eclipse console

[ Edited ]

I've searched on here and haven't  found a solution to this, so I thought I'd post in case someone had some insight on resolving this. Otherwise, I know that I will need to go through my program step by step in the debugger, which is difficult when multiple threads are running at once and it's a very large program.

 

I'm getting a "no stack trace" within my program. I suspect it is during some functionality that involves networking. Is there any way to trap this type of exception. Yes I do have my whole program wrapped in a try block for testing.

 

I'm using the Eclipse 1.0 plugin for BB.

 

Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: "no stack trace" in Eclipse console

Wherever you have your try...catch blocks, try also doing a System.out.println(e.getMessage()) to give you an idea of what the exception is.

 

If that is not enough, in each try...catch block, also put System.out.println("SOME_INDICATOR_OF_CODE") to find out where this error may be occurring. Since you have wrapped your whole code in a try..catch block, it's harder to find the exact culprit without stepping through the code.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: "no stack trace" in Eclipse console

If you're trying to get a stack trace into the event log, try surrounding your code with "catch (Throwable .." instead of "catch (Exception ...". If you are using catch(Throwable) anywhere, you might want to take a look at the debugging options for the simulator (under debug configurations) and consider setting "Do not stop execution when an exception is caught by catch(Throwable)".

 

I'd also strongly suggest upgrading to the latest plugin unless you have a compelling reason to stick with what you have.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Contributor
jasbeern
Posts: 17
Registered: ‎06-17-2010
My Device: C

Re: "no stack trace" in Eclipse console

Simulator does not show e.printStackTrace() of the exception. Sometimes its very difficult to debug the problem. Also added e.getMessage() at many places but it does not solve the purpose.

 

How we can see the stack trace in simulator while developing the application. It only says No Stack Trace :smileysad:

Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: "no stack trace" in Eclipse console

@jasbeern -- Two points:

 

1. you cannot see the stack trace in the simulator itself (unless the exception is written to the event log, either by not being caught or using EventLogger). The best way is to look at the simulator output console in Eclipse. If you debug (not run) an application, all output to System.out should show up there, including the output of printStackTrace().

2. The exception has to have a stack trace. This only happens if you use catch(Throwable) instead of catch(anything else). Java on the BB throws away the stack trace of any caught exception unless it is caught by catch(Throwable). To see this demonstrated, try debugging this code from Eclipse:

 

try {
throw new Exception("My exception");
} catch (Exception e) { e.printStackTrace(); }

try {
throw new Exception("My exception");
} catch (Throwable e) { e.printStackTrace(); }

(You might want to first check "Do not stop execution when an exception is caught by catch(Throwable)" in the Debugging tab of the debug configuration.) You don't need to step through it or anything, just look at the simulator output console in Eclipse when it runs.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
New Contributor
idarwin
Posts: 3
Registered: ‎09-14-2011
My Device: Bold(abandoned by BB), Playbook (abandoned by BB), Z10 (mailer unusable), Google Galaxy Nexus

Re: "no stack trace" in Eclipse console

2. ... Java on the BB throws away the stack trace of any caught exception unless it is caught by catch(Throwable).


 

 

I don't suppose anybody at RIM realizes how braindead this is? Probably not...

 

Ted, thank you for pointing out this misfeature so the three of us still maintaing BB5/6/7 Java-like code can work around it.

Java SE/EE/Android developer also doing BlackBerry development.
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: "no stack trace" in Eclipse console


idarwin wrote:

 

I don't suppose anybody at RIM realizes how braindead this is? Probably not...

 

Ted, thank you for pointing out this misfeature so the three of us still maintaing BB5/6/7 Java-like code can work around it.


Maybe it made sense at the time j2me was developed, which was a long time ago.

Using throwable is one of the many "specials" you kind of have to know, it is mentioned in the throwable api docs, but i would never have found it on my own.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter