×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    75

    Cool java.lang.RuntimeException: Blocking call performed in the event thread

    Hi all

    Following is code used by me to connect to Http serever.
    But am get the exception java.lang.RuntimeException: Blocking call performed in the event thread.
    when i try to hit the server with the same url for second time

    it shows exception here conn = (HttpConnection) Connector.open(URL);
    Code Used
    public String getResponseString(String URL) throws IOException
    { HttpConnection conn = null;
    InputStream servletStream = null;
    OutputStream os = null;
    StringBuffer xmlBuffer = new StringBuffer();
    String xmlString = null;

    try
    {
    if (conn != null)
    {
    conn.close();
    conn = null;
    }
    conn = (HttpConnection) Connector.open(URL);
    conn.setRequestMethod(HttpConnection.GET);
    if (conn.getResponseCode() == HttpConnection.HTTP_OK)
    {
    /* Send the parameters to the servlet via GET method */

    os = conn.openOutputStream();
    os.flush();

    servletStream = conn.openDataInputStream();
    int ch;

    while ((ch = servletStream.read()) != -1) {
    xmlBuffer.append((char) ch);
    }

    xmlString = xmlBuffer.toString();

    if (servletStream != null) {
    servletStream.close();
    }

    if (conn != null) {
    conn.close();
    }

    if (os != null) {
    os.close();
    }
    System.out.println("Instructions are: " + xmlString);
    return xmlString.trim();
    } else {

    AlertType.WARNING.playSound(Display.getDisplay(this));
    Display.getDisplay(this).setCurrent(new Alert("Connection Error", "Unable to connect try Again.", null, AlertType.WARNING));
    }

    ==========================================================

    Exception got

    =================
    java.lang.RuntimeException: Blocking call performed in the event thread
    at javax.microedition.lcdui.DisplayEventHandlerImpl.preemptDisplay(), bci=50
    at com.sun.midp.security.PermissionDialog.<init>(), bci=268
    at com.sun.midp.security.SecurityHandler.askUserForPermission(), bci=14
    at com.sun.midp.security.SecurityHandler.checkForPermission(), bci=258
    at com.sun.midp.security.SecurityHandler.checkForPermission(), bci=15
    at com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(), bci=40
    at com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(), bci=18
    at com.sun.midp.main.CldcAccessControlContext.checkPermissionImpl(), bci=71
    at com.sun.j2me.security.AccessControlContextAdapter.checkPermission(), bci=4
    at com.sun.j2me.security.AccessController.checkPermission(), bci=23
    at com.sun.j2me.security.AccessController.checkPermission(), bci=3
    at com.sun.midp.io.j2me.http.Protocol.checkForPermission(), bci=32
    at com.sun.midp.io.j2me.http.Protocol.openPrim(), bci=2
    at javax.microedition.io.Connector.openPrim(), bci=327
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
    at MGreetings.getResponseString(), bci=20
    at MGreetings.getCorrespondURL(), bci=381
    at MGreetingsCanvas.doToNavigate(), bci=7
    at MGreetingsCanvas.NavigateBackwards(), bci=19
    at MGreetingsCanvas.backCommandProcess(), bci=5
    at MGreetingsCanvas.readInput(), bci=254
    at MGreetingsCanvas.keyPressed(), bci=15
    at javax.microedition.lcdui.CanvasLFImpl.uCallKeyPressed(), bci=19
    at javax.microedition.lcdui.DisplayableLFImpl.uCallKeyEvent(), bci=146
    at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=30
    at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277
    at com.sun.midp.events.EventQueue.run(), bci=179
    at java.lang.Thread.run(Thread.java:619)
    Last edited by ayyanar7; 2010-04-30 at 12:48.

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Are you calling that method either in CommandAction() or keypressed()?
    was this exception thrown on the emulator or on the real device?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    75

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Inside keypressed am calling backCommandProcess() which in turn calls NavigateBackwards() and then finally from NavigateBackwards(), am calling this method.

    And am getting the error in emulator itself.

    Thanks in advace.

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Quote Originally Posted by ayyanar7 View Post
    Insid ekeypressed am calling backCommandProcess() which in turn calls NavigateBackwards() nad then finally from NavigateBackwards(), am calling this method.

    And am getting the error in emulator itself.

    Thanks in advace.
    Well I am sorry, I have not found the name of the methods that you have just share.However I would recommend thta if you are opening the HTTP connection in either commandAction() or inside the keypressed() then please dont make the connection in either of these methods. Kindly put your connection opening code in the separate thread. Let us know the results.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    75

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Thanks Raj.
    so you mean i need to use thread here.
    Ok.I ll try and let you know.

  6. #6
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    75

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Thanks raj

    That exception is cleared but now i got different exception
    java.lang.SecurityException: Application not authorized to access the restricted API
    at com.sun.midp.security.SecurityHandler.checkForPermission(), bci=275
    at com.sun.midp.security.SecurityHandler.checkForPermission(), bci=15
    at com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(), bci=40
    at com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(), bci=18
    at com.sun.midp.main.CldcAccessControlContext.checkPermissionImpl(), bci=71
    at com.sun.j2me.security.AccessControlContextAdapter.checkPermission(), bci=4
    at com.sun.j2me.security.AccessController.checkPermission(), bci=23
    at com.sun.j2me.security.AccessController.checkPermission(), bci=3
    at com.sun.midp.io.j2me.http.Protocol.checkForPermission(), bci=32
    at com.sun.midp.io.j2me.http.Protocol.openPrim(), bci=2
    at javax.microedition.io.Connector.openPrim(), bci=327
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
    at MGreetings.getResponseString(MGreetings.java:197)
    at MGreetings.getCorrespondURL(MGreetings.java:309)
    at MGreetingsCanvas$2.run(MGreetingsCanvas.java:579)
    In finally...
    Last edited by ayyanar7; 2010-04-30 at 14:05.

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    The connection you are trying to open is not allowed for your application, thus you are getting this security exception.

    on javax.microedition.io.Connector.open();

    What type of connection you are trying to open here ? (what do you want to do ?)

    You may need to set permissions for it and sign the midlet.

    thanks,
    ~Amitabh

  8. #8
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    75

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Thanks amit

    But for first hit its not showing the exception.
    I am trying to get audio from server using httpconnection

  9. #9
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Quote Originally Posted by ayyanar7 View Post
    Thanks raj

    That exception is cleared but now i got different exception
    java.lang.SecurityException: Application not authorized to access the restricted API
    That sweet to see..
    As im2amit suggested....take care of that.
    In addition to that, are you testing the app on the emulator or on the device?
    In either of the case you have to click on the Yes command when devcie/emulator must be displaying the alert to you something like this..

    "allow application to send or receive the data from/or to the internet...
    Please click the yes command and see whether this works or not..
    Please check the application setting by going to the setting->application manager->suite setting->
    that here "Allowed" is set.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    But for first hit its not showing the exception.
    I am trying to get audio from server using httpconnection
    So when and where does it show this exception?

    Are you testing on emulator or some device (which) ?

  11. #11
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    Hello Sir,

    I am getting the same exception (Error : java.lang.RuntimeException : Blocking call performed in the event thread).I am developing the app on Nokia Asha SDK 2.0 and the app plays a random song via the internet whose url is hardcoded in the app.I have previously developed this app using Nokia Asha SDK 2.0 and it worked fine but when i am using the same source code using Nokia SDK 1.0(AKA Nokia Asha SDK) then it is giving me the above error.Please help me.You can download my app to diagnose the problem at :- https://www.dropbox.com/s/s3qvj99j0a...MediaPlaye.zip Please contact me at :- zoebali.maknojia@gmail.com

  12. #12
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,734

    Re: java.lang.RuntimeException: Blocking call performed in the event thread

    The cause is what it says: blocking operations has to be moved into secondary thread(s) in order to avoid blocking of the main, UI thread.
    Here is the general description of the behavior: http://developer.nokia.com/Resources...-commands.html, and here is one listing the actual API calls treated as blocking ones: http://developer.nokia.com/Resources...tive-apis.html, this page provides the actual explanation too: blocking "threat" comes from the permission checking dialog, so whenever it may appear (it does not have to), that operation is considered a blocking one.

Similar Threads

  1. S60 5th Edition Emulator Crashes
    By Yagiza in forum Symbian Tools & SDKs
    Replies: 26
    Last Post: 2010-08-07, 21:24
  2. Child Thread call failed
    By kunlamp in forum Symbian
    Replies: 0
    Last Post: 2009-11-10, 06:46
  3. Epoc is constantly crashing
    By elviin in forum Symbian Tools & SDKs
    Replies: 34
    Last Post: 2009-10-10, 21:24
  4. changing event type from intenet call to voice call
    By tal.shahar@mobile-mx.com in forum Symbian
    Replies: 0
    Last Post: 2009-01-12, 09:49
  5. Blocking incoming call...
    By amol_benare604 in forum Symbian
    Replies: 3
    Last Post: 2009-01-08, 11:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×