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
New Developer
Posts: 2
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

IllegalStateEx: UI engine accesed without hoding the event lock in LocalDevice.getLocalDevice()

[ Edited ]

I do get IllegalStateExeption: UI engine accesed without hoding the event lock, when I call LocalDevice.getLocalDevice(). In code below do get following list: 1, 2, 3, 4, Exception: java.lang.IllegalStateExeption: UI engine accesed without hoding the event lock.

 

Interestingly, but this code was working yesterday.

 

What does this exception means and how to solve this problem?

 

The device is 8820 4.2.2.160 version. BlackBerry JDE is 4.2.1.

 

Thanks! 

 

 

try { testList = new List("Testing", List.EXCLUSIVE); testList.append("1", null); testList.setCommandListener(this); testList.append("2", null); testList.addCommand(Commands.CMD_EXIT); testList.append("3", null); display.setCurrent(testList); testList.append("4", null); try { local = LocalDevice.getLocalDevice(); testList.append("5", null); agent = local.getDiscoveryAgent(); testList.append("6", null); agent.startInquiry(DiscoveryAgent.GIAC, this); testList.append("7", null); } catch (BluetoothStateException ex) { testList.append("Problem in searching the Bluetooth devices", null); testList.append("Exception: " + ex.toString(), null); } } catch (Exception ex) { testList.append("Exception: " + ex.toString(), null); }

Message Edited by aurelije on 07-16-2008 01:11 PM
Retired
Posts: 86
Registered: ‎07-11-2008
My Device: Not Specified

Re: IllegalStateEx: UI engine accesed without hoding the event lock in LocalDevice.getLocalDevice()

Are you certain that it's the call to LocalDevice.getLocalDevice() that's the source of the error?  I.e. if you attach the debugger or to your app or you throw in print statements, is that definitely the line of code that results in this exception? 

 

Typically, this exception indicates that you are updating the UI from a non event thread.  Moreover, in the MIDP UI space, you should be more or less immune to this sort of consideration, since the concept of an event thread doesn't necessarily apply to MIDP (unless of course you're mixing MIDP UI with BlackBerry UiApplication functionality).  As a workaround, you could try wrapping your UI update calls in invokeLater(), but more importantly, we'll need to identify the source of this error being thrown assuming that you're operating in a pure MIDP setup. 

 

More information on the event thread can be found here:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

Brian Zubert
Technical Partnership Manager
Research In Motion
Highlighted
New Developer
Posts: 2
Registered: ‎07-16-2008
My Device: Not Specified

Re: IllegalStateEx: UI engine accesed without hoding the event lock in LocalDevice.getLocalDevice()

My application is pure MIDP. We already had application for HP iPAQ that we are porting to BB. And now we are trying bluetooth connection with barcode reader. I did not used debugger. I have used printing in TextBox after every code line, and printing stops after LocalDevice.getLocalDevice()

 

Now I do call LocalDevice.getLocalDevice() method from new thread, and it seems to work O.K.:

 

(new Thread() {
    public void run() {
        try {
             myDevice = LocalDevice.getLocalDevice();
        } catch (BluetoothStateException ex) {
             testBox.insert("Exception u run(): " + ex + "\n", testBox.size());
        }
    }
}).start();

New Developer
Posts: 3
Registered: ‎02-19-2009
My Device: Not Specified

Re: IllegalStateEx: UI engine accesed without hoding the event lock in LocalDevice.getLocalDevice()

Getting same error in Pure MIDP enviroment. i am using BB 8700 and JDE 4.2.1.
BlackBerry Development Advisor
Posts: 15,301
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: IllegalStateEx: UI engine accesed without hoding the event lock in LocalDevice.getLocalDevice()

What BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  Are you able to reproduce this in version 4.5.0?  Can you provide a code snippet that is triggering the exception and note the line that is throwing the exception.

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