BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-19-2009, 01:06 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default HttpConnection giving 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 Line is not reached at all.
System.out.println("cnx="+cnx+ " " +cnx.getResponseCode());

if(cnx.getResponseCode()==HttpConnection.HTTP_OK){
is=cnx.openInputStream();
byte [] data = readFromStream(is);
app.responseFromServer =new String(data);
is.close();
}
cnx.close();
}
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  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Distressed pkg --Genuine Dell NY313 Black Toner Cartridge for Dell 5330dn - OEM
$49.95
Distressed pkg --Genuine Dell NY313 Black Toner Cartridge for Dell 5330dn - OEM pictureV7 Replacement Battery DELL LATITUDE E5400 OEM# 0KM752 312-0762 KM742 KM769 6 CE
$85.97
V7 Replacement Battery DELL LATITUDE E5400 OEM# 0KM752 312-0762 KM742 KM769 6 CE pictureGenuine OEM Dell 3200MP Osram Replacement Lamp & Housing 310-2328
$79.99
Genuine OEM Dell 3200MP Osram Replacement Lamp & Housing  310-2328 pictureOEM Genuine Dell Symbol Cyclone M2007 Barcode Laser Scanner M1362 CN-0M1362
$29.99
OEM Genuine Dell Symbol Cyclone M2007 Barcode Laser Scanner M1362 CN-0M1362 pictureDell Toner Cartridge - Magenta - Laser - High Yield - 2500 Page - 1 / Pack - OEM
$114.97
Dell Toner Cartridge - Magenta - Laser - High Yield - 2500 Page - 1 / Pack - OEM picture






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