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
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Uncaught exception, application not responding

[ Edited ]

I have seen a handful of posts about this problem, and from what i understand its an issue with filling up the event queue.  whats confusing me is this ...

i have an object extending defaulthandler to parse an xml file.  in my endElement function i have my processing logic, and throughout the function i have debug statements.  the statements are all like:

if (mydebugvar) System.out.println("the debug statement") ... and i set mydebugvar statically in the file.

If i turn off debugging by settings mydebugvar to false, my app crashes with this error.  if i keep it on, it works fine.  the only thing that uses that variable at all is those debug statements, so im not sure why it would make any difference.

unless the processing time required for the simple println allows the other processes to go through the queue. but if thats the case, i dont know what it is that i need to fix so i can get it to run w/o the debug statements. 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Uncaught exception, application not responding

My experience suggests this problem is most often caused by running code on the Event Thread.  Are you doing your parsing on the Event Thread or in a background Thread?  The correct answer is background Thread....

Developer
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: Uncaught exception, application not responding

I have a network thread that waits for requests and then goes and gets the data, and i do the parsing and all the processing in the run of that thread (or a function called from run). so that shouldnt be causing the problems from what i can tell.

Developer
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: Uncaught exception, application not responding

So apparently, I cannot have my run() method in my thread call a local function to do the processing ... when the code is in a seperate function, it crashes (if im not printing debug statements). when the code is back in the run() method, it seems to work OK with or without printing debug.  Im not sure why that is but im assuming its some fundamental thread/sync/java thing im just ignorant of.

Of course the problem may still be there and i just havent seen it yet.  Is there something I'm missing here?

 

Thanks

Developer
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: Uncaught exception, application not responding

Ok i was wrong since its doing it again. The other threads mentioned wrapping the enterEventDispatcher in try/catch to try to see the dump but it doesnt seem to work.  Does anyone have any suggestions on troublehooting?

Developer
Posts: 41
Registered: ‎09-28-2009
My Device: Not Specified

Re: Uncaught exception, application not responding

I have also seen this exception when an app contains synchronized methods which get deadlocked.    Probably not very common, but thought I would point it out.

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Uncaught exception, application not responding

Let us make absolutely sure you are not running on the Event Thread first.

 

Add the following code to somewhere convenient, say your endElement() processing:

 

if ( Application.isEventDispatchThread() ( {

throw new RuntimeException("Is Running on the Event Thread");

}

Developer
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: Uncaught exception, application not responding

negative, doesnt seem to throw that.

so when running on the simulator, i have this in endElement

System.out.println( "!!DEBUG: entered endElement with " + localName );

 

when i comment it out, it crashes. when i uncomment, it runs fine. so so weird.

although i think even with it uncommented, it crashes on live device.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Uncaught exception, application not responding

This exception always forces a stack trace of all running applications. You can retrieve the stack trace from the event log.

 

One question: how are you synchronizing your "foreground" task with the background?  In other words, what is your UI thread doing while this data is being parsed?

 

 

 

 

 

Developer
Posts: 111
Registered: ‎10-01-2009
My Device: Not Specified

Re: Uncaught exception, application not responding

ill try to take a look at the event log ... i thought it was ALT+LGLG but maybe that was on older devices.

im not sure about synching the foreground process. my UI process is just displaying an empty list, and i use a callback to have my networkthread do something in my UI (popuplate the list and refresh the display) when its done.