BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-19-2009, 01:27 AM   #1
deepakjain
Knows Where the Search Button Is
 
Join Date: Jun 2009
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 17
Default HttpConnection throwing exception

Please Login to Remove!

Hi,

I am using a BB Curve 8700(trackwheel) device.I have been developing applications for blackberry and am new to this. I have developed an application which connects to the server on internet and gets some response.

Some Facts :
1. I have a Vodafone connection(India) and all services are activated.
2. I am able to browse the internet from the device browser.
3. The application is signed.
4. The Http is handled in a seperate thread.
5. Device OS version is 4.2.1.114


Here is the code...

public void run() {
HttpConnection cnx;
InputStream is;
try
{
System.out.println(mainURL); //This is getting printed
cnx = ( HttpConnection )Connector.open( mainURL ); //Exception here

//This sysout is not reached at all
System.out.println("cnx="+cnx+ " " +cnx.getResponseCode());

if(cnx.getResponseCode()==HttpConnection.HTTP_OK)
{
//Do some processing here
}
cnx.close();

} //end of Try

catch(Exception e)
{
returnResp=false;
System.out.println("Exception = "+e); //Displays java.lang.NPE
}

The Connector.Open() is throwing an exception and a Null Pointer Exception is caught.Verified that 'mainURL' is not NULL. Dont know why NPE is thrown !!!

This same piece of code works perfectly fine on my other BlackBerry Bold device(9000) with the same SIM card. All basic settings are similar in both the devices.

Please suggest me a solution to make this work.Thanks in advance.
Offline  
Old 11-19-2009, 08:49 AM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

Have you looked at the stack trace? You have this "do some processing here" which could be anything - this is likely where your NPE is getting thrown.

Get all of this code out of the try/catch - it shouldn't be there.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Lot of OEM APPLE iPAD LCD And White Front Glass Replacement 6091l-1402C picture

Lot of OEM APPLE iPAD LCD And White Front Glass Replacement 6091l-1402C

$17.99



Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013 picture

Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013

$40.90



NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch picture

NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch

$31.90



A1618 NEW OEM Battery for MacBook Pro 15

A1618 NEW OEM Battery for MacBook Pro 15" Retina A1398 Mid 2015 020-00079

$43.90



OEM Battery for MacBook Pro 17

OEM Battery for MacBook Pro 17" A1309 A1297 Early 2009 Mid 2009 2010 MC226

$40.90



NEW OEM A1618 Battery for Apple MacBook Pro 15” Retina 99.5Wh A1398 Mid 2015 picture

NEW OEM A1618 Battery for Apple MacBook Pro 15” Retina 99.5Wh A1398 Mid 2015

$43.90







Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.