×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    7

    HttpConnection throws NumberFormatException on Nokia 6600

    Hi,

    we run into a strange problem, which, of all devices we tested, occurs only on Nokia 6600.

    We use http to download various resources from our server.

    now, call to any method of HttpConnection that actually makes the HttpConnection object to talk to the server results with NumberFormatException!

    the code is straightforward:

    Code:
        private void perform(GetData requestWrapper){
            HttpConnection conn = null;
            InputStream in = null;
    
            String path = requestWrapper.path();
            try {
                conn = (HttpConnection)Connector.open(url+path);
                conn.setRequestMethod(HttpConnection.GET);
    
                int rc = conn.getResponseCode();
                if (rc != HttpConnection.HTTP_OK) {
                	new OnHttpError(url+path, "HTTP "+rc).execLater();
                }
                else{
                	in = conn.openInputStream();
                	String type = conn.getType();
                    long len = conn.getLength();
                	requestWrapper.setResult(process(type, in, len));
                	requestWrapper.execLater();
                }
    
            } catch (ClassCastException e) {
            	new OnHttpError(url+path, "Not an HTTP URL").execLater();
            } catch (Throwable e) {
            	new OnHttpError(url+path, "IO error:"+e).execLater();
            } finally {
            	try{
            		if (in != null) in.close();
            	}catch(IOException e2){}
            	try{
            		if (conn != null) conn.close();
            	}catch(IOException e2){}
            }
        }
    Now, on 6600, ANY POSSIBLE request will fail exactly on the line
    Code:
     int rc = conn.getResponseCode();
    If that is ommitted, it fails on
    Code:
    in = conn.openInputStream();
    or
    Code:
    String type = conn.getType();
    depending on which is called first.

    the exception that we get there is, for example:
    Code:
    java.lang.NumberFormatException: 772
    The actual number is constant for given url (assuming server response does not change), but it varies across different urls. It's 212 for www.google.com, but 9242 for www.yahoo.com. Funny.


    we double checked that the requests reach (at least our) servers and are handled properly. The AP used is GPRS, not WAP.
    The same midlet successfully opens and uses a plain socket connection to our server over the same AP. it's only HTTP which fails.
    Firmare we're using is 4.09.1. I know that 6600 is a bit old nowadays, but we want to have maximum portability available.

    looking at MIDP spec, it looks like the only reason for this exception being thrown is that HttpConnection is trying to parse the number as Byte.

    Anybody has got any ideas?
    Thanks
    Greg

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    7

    Re: HttpConnection throws NumberFormatException on Nokia 6600

    Hi,

    maybe the other way round...

    can anyone confirm that they have successfully used http connections on nokia 6600 in their midlets? I'm trying to figure out where the problem sits..

    greg

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

    Re: HttpConnection throws NumberFormatException on Nokia 6600

    I have used multiple MIDlets with network access on various firmware versions on 6600. So the connections work, however was quite a few issues with the Java implementation on 6600 so there might be some issue which casues problems for your code.
    http://wiki.forum.nokia.com/index.php/Portal:KB_Java

    As the 6600 is CLDC 1.0 phone, have you tried compiling the MIDlet with a SDK which supports CLDC 1.0 only (I know that you have correctly defined CLDC version in the tool as you are able to install the MIDlet on the device...)

    Hartti

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    7

    Re: HttpConnection throws NumberFormatException on Nokia 6600

    Thanks for the reply,

    the client comes from our deployment pipeline, which
    1) compiles the client components with Sun's WTK with correct CLCD settings
    2) assembles selected components together basing on phone capabilities (only the components that compile with CLDC 1.0 may be included in resulting CLCD 1.0 midlet)
    3) preverifies the resulting jar file with preverifier included in Sun's WTK (again, with appropriate CLDC settings and checking for forbidden constructs).

    All this on linux server.

    We are trying to be very careful about the compatibility, however, 6600 is the only CLDC 1.0 phone we have for testing....

    Where would I get the CLDC 1.0 ONLY SDK??

    What I don't understand is, how come the exception is java.lang.NumberFormatException: 772. 772 is the correct number representation!

    Another thing is, such a bug would never let 6600 go through any QA tests. Should I consider my operator's gateway messing with the contents of the HTTP response..?

    greg

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

    Re: HttpConnection throws NumberFormatException on Nokia 6600

    S60 2nd Edition FP1 SDK from here
    http://www.forum.nokia.com/info/sw.n..._for_Java.html
    supports only CLDC 1.0

    I do not really understand the NumberFormatExecption message either. I was thinking/guessing out loud...

    Hartti

Similar Threads

  1. which phones for laptop
    By dvdljns in forum PC Suite API and PC Connectivity SDK
    Replies: 2
    Last Post: 2006-02-14, 12:58

Posting Permissions

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