×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    7

    Exclamation Strange situation

    I have a mobile device: Nokia 9300.

    And I have created an application to work with HTTPConnections.

    When I try to load a data via HTTPConnection I get the following error message:

    java.lang.ClassNotFoundException: com/symbian/midp/io/protocol/Http/Protocol

    I used only standard J2ME classes. And my app works fine on Motorola phones, for example. But on Nokia 9300 I get this error.

    Below there is a part of my code that causes the problem:

    final HttpConnection shopsHttpConnection = (HttpConnection)Connector.open(cmdGetShops);
    final InputStream shopsLoadingStream = shopsHttpConnection.openInputStream();
    final InputStreamReader shopsLoadingStreamReader = new InputStreamReader(shopsLoadingStream, ENCODING);


    Any ideas ?

    Thank you.

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Strange situation

    so are you using java.microedition.io.HttpConnection or are you trying to import some other classes? Which method call throws the exception? What is the URL in the cmdGetShops variable? Have you tried without final keyword?

    Hartti

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    7

    Post Re: Strange situation

    I used only standard java2me classes. No additional libraries for networking were used. Only java.io.* and javax.microedition.io.* classes.

    ------------------------------------------------
    Code that causes exception is marked as bold.
    ------------------------------------------------

    final String HTTP_COMMAND_SUFFIX_GET_SHOPS = "/ShopsListXML?OpenPage";

    final SettingsModel settingsModel = SettingsModel.getInstance();

    final String cmdGetShops = settingsModel.getServerAddress() + HTTP_COMMAND_SUFFIX_GET_SHOPS;

    final InputConnection shopsHttpConnection = (InputConnection)Connector.open(cmdGetShops);
    final InputStream shopsLoadingStream = shopsHttpConnection.openInputStream();


    ------------------------------------------------

    Use of final keyword should not lead to such problems. I tried with and without final keyword - the whole picture is the same.

    cmdGetShops address looks like: http://www.server.com/ShopsListXML?OpenPage
    When an application accesses server by this address server returns XML result to be parsed.

    I suspect the problem occurs because some components are missing on the device operating system.

    I compiled this application by Sun java compiler (version 1.4).

    I tried to run this application on Motorola RAZR V3 (CLDC 1.0, MIDP 2.0). On Motorola's device this application works ok. But on Nokia 9300 - fails.

    I would like to understand the source of the problem. And how to avoid it.

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Question Re: Strange situation

    hi rafael,

    can you try to run standard Sun's http sample precompiled jars that come with WTK installation on that phone? they will allow you to check if problem is with phone or with your implementation,

    regards,
    Peter

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    7

    Post Re: Strange situation

    I tried standard http demo midlet. It does work ok.

    I will compare this example with my code.

    thank you.

  6. #6
    Registered User
    Join Date
    Jun 2006
    Posts
    7

    Smile Re: Strange situation (resolved)

    Code in sample and my code are semantically identical.

    But the problem had an unexpected source.


    I have a text field in Settings screen: serverAddressField

    This field declared as:

    TextField serverAddressField = new TextField("Server address:",
    settingsModel.getServerAddress(),
    MAX_SERVER_ADDRESS_SYMBOLS,
    TextField.URL);


    TextField.URL flag allows to specify CAPITAL letters in URL too.

    And when a user specifies any http address the first letter in word "http" is adding as a capital letter. And instead of "http://www.server.com" we have "Http://www.server.com".

    And this big first letter H in server address causes the problem.

    To resolve this - I just needed to convert address to lower case letters.
    Last edited by rafael.osipov; 2006-06-27 at 09:59.

  7. #7
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Strange situation

    hi Rafael,

    well, we learn both something: "protocol" is found by class lookup and it need to be lowercase, if we provide "Http" runtime error is thrown,

    sample code:

    void getHttpConnection() throws Exception {
    String url = "Http://www.yahoo.com/";
    HttpConnection c = null;
    InputStream is = null;
    try {
    c = (HttpConnection)Connector.open(url);
    is = c.openInputStream();
    // do something with data
    get_resultsForm().setString("::no errors::");
    }catch (Exception ex){
    get_resultsForm().setString("::ERROR::\n");
    get_resultsForm().setString(ex.toString());
    throw new Exception(ex.getMessage());
    } finally {
    if (is != null)
    is.close();
    if (c != null)
    c.close();
    }
    }

    it will throw exception:

    .........
    java.lang.ClassNotFoundException: com/sun/midp/io/j2me/Http/Protocol
    at javax.microedition.io.Connector.openPrim(Connector.java:292)
    at javax.microedition.io.Connector.open(Connector.java:219)
    at javax.microedition.io.Connector.open(Connector.java:187)
    at javax.microedition.io.Connector.open(Connector.java:169)

    that means that we need to extract "protocol" part from an url and make it lowercase,
    we cannot do that with entire url in case if for example we are making RESt request to serach engine with case sensitive arguments,

    glad that could help you

    regards,
    Peter Blazejewicz

  8. #8
    Registered User
    Join Date
    Jun 2006
    Posts
    7

    Smile Re: Strange situation

    Thank you.

Similar Threads

  1. Strange UI behaviour N90
    By mateen_maldar in forum Symbian User Interface
    Replies: 3
    Last Post: 2006-05-14, 10:21
  2. Some thing strange in my email app?????
    By kamodo in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-12-17, 14:18
  3. VERY strange memory full problem..
    By etamburini in forum Mobile Java General
    Replies: 9
    Last Post: 2005-05-17, 15:50
  4. Strange bug on N3650 with Firmware 4.13
    By NeoEgoism in forum Symbian
    Replies: 1
    Last Post: 2004-05-04, 04:08
  5. Wav sound strange problem on 7650
    By FatalError in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2003-08-04, 15:12

Posting Permissions

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