If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

how to use Throwable.printstacktrace() with System.err

Hi,

I'm trying to find someway to get a stack dump out of a Throwable

into something I can manipulate programmatically ( not just dump to the default

System.err).

 

J2SE provides several options,

 

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html

 

while I appreciate that the phone is limited, I would expect there would be some mechanism

to facilitate remote debugging ( which I what I am attempting) that allows stack

capture and reporting. But, I don't see an obvious way to easily get the stack info with supported

methods. System.err= new PrintStream() isn't allowed for example.

 

What is the best way to do this?

Thanks.

 

Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: how to use Throwable.printstacktrace() with System.err

The stack trace can be viewed in the BlackBerry event log.  You can view it by holding down Alt and pressing LGLG.  There is no way to programmatically access it though.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

Thanks. I would note however that for mobile/resource limited development it is nice if you have some way to get

debug and failure info with little overhead and in an AUTOMATED way. Just something to keep in mind

for future designs. I hate to beat this to death but there is a big difference in design philosophy

between people used to Windoze and others who don't expect data processing to always be an interactive

task. This one case is rather trivial but you have this same problem come up in other places-

many websites with complicated and intersting data only offer it in some mode predicated

on it being read by a human rather than another computer.

Thanks again.

 

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

[ this is a bit confusing as I originally thought I had the problem fixed but essentially I'm just asking for more

info right now- where does system.out go and how do I interpret System messages about 0x33?]

 

ok, so I started getting a mystery NPE and was able to get the stack trace as you suggested. I expected a bit

of obfuscation due to the RIM tools but AFAIK, after clearing the log and running the program, I got this entry which doesn't

say much about my code as well as some other stuff that does point to my code but is still quite confusing.

Do you have a link to the destination of system.our and system.err? I'm trying to label my stuff

and sort this mess out. I got rid of one problem by removing battery for a while and I keep getting a cryptic system

message of no obvious origin( the AJA... is my code name but i would like a link to interpretting the rest if possible-

what is CMM and 0x33? ). Thanks.

 


Name: System
GUID: 97c9f5f641d25e5f
Time: Sep 14, 2008 14:34:35
CMM: AJA237_04_0_4545(580) no sig from 0x33

 

The confusing npe,

 

Name: NullPointerException
GUID: 9c3cd62e3320b498
Time: Sep 14, 2008 11:27:49
No detail message
net_rim_bb_email-2
IconFetcher
fetchIcons
0x6194
net_rim_bb_email-2
RibbonUpdater$RibbonUpdaterEvent
<private>
0x7772
net_rim_bb_email-2
RibbonUpdater$RibbonUpdaterEvent
run
0x761E
net_rim_cldc-10
RunnableThread
run
0xA031

but it does seem to happen after my code runs. I did pull the battery and restart and one NPE went away but I still get the above.

Also, I do get a stack trace in my code but it doesn't seem to have anything to do with my printStackTrace(),

 

 

 

 

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

"no sig from 0x33" is a system message that your application does not carry a signature signer 0x33. Since no 3rd party applications get this signature, I think you can safely ignore this message.

 

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

Is it in response to a request or somekind? If I accidently switched to something unavailable and it wasn't

caught at install time I guess that could explain a null pointer.

 

I'm having a hard time finding my system.out and system.err output- should this come up with the alt-lglg screen too?

 

I did get one stack trace from my code but it didn't appear to be in the location of my printStackTrace()...

I had the print in a method like this,

 

System.err.println("dumping the npe");
     ef.printStackTrace();
     System.err.println("dun dumping the npe"); 

 last_error(xxx,ef);

 

but the only stack trace I got was in a differnt method and I didn't save it. The last_error method records the labelled

error so I'm pretty sure it is coming from this code,

 

BrowserContent bc= rs.getBrowserContent(hc,appx,e);
eloc=1; 

eloc is used in the error label to narrow the location and none of the arguments appear to be null

 

catch (Exception ef)
    {   String xxx= "start_page_Err"+eloc;
     if (rs==null) xxx+="rs is null";
     if ( appx==null) xxx+="appx is null";
     if (hc==null) xxx+="hc is null";
     if (e==null) xxx+="e is null";

 

so I'd have to suspect something dumb inside the method ( probably due to a change I made in hc but I have no

idea where to look and I thought a stack trace would be easy).

 

[ and no, I haven't tried this on the emulator recently as the code had been working fine and I thought I backed

out the changes but, in any case, this is a mystery that I should be able to fix if I could at least isolate an offending

variable and location ]

 

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

ok, I did fix my immediate problem, and was able to follow the idea that setting a variable to null could

cause an npe later, LOL.

 

public void close() throws IOException {
      [...]

      // this may be asking for trouble but leet's see
     //data=null;
    }

 

but, it would be nice to know how to get stuff into the system log. What I finally had to do was email myself a status report,

and it was quite obvious what happened,  

 

err:connxxcall:http://www.[...]/t1.php&build=1221425498;deviceside=true getType()
err:connxxcall:http://www.[...]?cucamp=AJA237_04_0/t1.php&build=1221425498;deviceside=true close()
err:latioerr: start_page_Err0java.lang.NullPointerException

 

but it would have been nice to get a stack dump and find out what happened to the extent allowed by any any remaining symbol information

( IIRC the tools obfuscate and compress somewhat and presumably remove names etc).

 

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: how to use Throwable.printstacktrace() with System.err

The System.out and System.err streams can be seen in the BlackBerry JDE while debugging.  They are not stored on the device.

 

The EventLogger class can be used to write information to the BlackBerry event log that is shown when you press Alt+LGLG.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

[ Edited ]

Do you know offhand if it can throw and IllegalThreadStateException ?

Obvisouly, I've now got a lot of hacked up code and I've given up on printStackTrace() but I just got a status

dump from my (multi-threaded code with lots of UI and open network things ) that suggests this is aborting between

the m_last_erro assignment and the call to aoffix 

 

synchronized (glock) {m_last_error=x; }    
 e.printStackTrace();
  if (app!=null)
  {  aoffix(app.m_error_stack,"latioerr: "+x);}

 

[ never mind- it turned out the last erro was the threadstate, and app is probably null so stacktrace not likely

to be an issue. Thanks ]

Message Edited by marchywka on 09-15-2008 03:46 PM
Please use plain text.
New Developer
chico95
Posts: 23
Registered: ‎09-16-2008
My Device: Not Specified

Re: how to use Throwable.printstacktrace() with System.err

[ Edited ]
this was in error
Message Edited by chico95 on 10-02-2008 05:03 AM
Please use plain text.