Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums on April 1st. BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com


Reply
Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL
Accepted Solution

connection problem, using Connector.open() ???

while m trying following code::

HttpConnection conn=(HttpConnection)Connector.open("http://www.nasa.gov/rss/hurricaneupdate.rss");

 

my thread is stucked on this line:

conn.openInputStream();   

 

 

and after a long long time it gives IllegalStateException, can anybody suggest the reason or alternative??


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: connection problem, using Connector.open() ???

what does the detail message of the exception say?

do you execute the code on a separate thread? networking should not be done on the main event thread.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: connection problem, using Connector.open() ???

I m creating new thread in MainScreen:::

 

 

new Thread(){
            public void run() {
                try {
                   Document doc;
                   HttpConnection hconn=(HttpConnection)Connector.open("http://www.nasa.gov/rss/hurricaneupdate.rss");
                   DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                   docBuilder.isValidating();


                   doc = docBuilder.parse(hconn.openInputStream());     //this is the problem, moreover hconn.openInputStream() is actul problem everything runs before this              


                   doc.getDocumentElement().normalize();
                   NodeList list = doc.getElementsByTagName("Item");
                   add(new LabelField("Loading list"));
                   for(int i=0;i<list.getLength();i++){
                        Node node=list.item(i);
                        add(new LabelField(node.getNodeName()));
                   }
                   add(new LabelField("Loading Ends"));
                } catch (IOException e) {
                    add(new LabelField(e.getMessage()));
                } catch (SAXException e) {
                    add(new LabelField(e.getMessage()));
                } catch (ParserConfigurationException e) {
                    add(new LabelField(e.getMessage()));
                }
            };
        }.start();
        
        setTitle("RSS Demo");       
    }

 

 


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: connection problem, using Connector.open() ???

 

try to download the file without a parser first, best to analyze problems like this step for step.

I usually use

http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/io/IOUtilities.html#streamToBy...

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: connection problem, using Connector.open() ???

the problem is that hconn.openInputStream() is not even returning stream,  it stucks on that line and alter long time simulator says "IllegalStateException"


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: connection problem, using Connector.open() ???

 

can you open the file in the BB browser?

can you download the file with a junit test?

can you download the file on the simulator?

did you start the mds simulator or use deviceside=true?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: connection problem, using Connector.open() ???

bb borwser is not opening any page, and say unable to connect selected mds,

but the net is connected , i can open pages in Browserfield, other than that i dont know junit

and what is the purpose of mds?? i m not using it


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: connection problem, using Connector.open() ???

 

the mds simulator simulates the mds (mobile data service). the simulator uses it to connect to the internet. it can connect without it when you use ;deviceside=true.

read the sticky thread about network connections and some of the linked articles to give you some basics.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: connection problem, using Connector.open() ???

And while reviewing the basics of network processing, you should perhaps review the Event Thread. 

 

"the problem is that hconn.openInputStream() is not even returning stream,  it stucks on that line and alter long time simulator says "IllegalStateException""

 

This is caused by your Exception handling attempting to add a LabelField to the screen - however your exception handling is running in your connection Thread.  So you get an IllegalStateException because you must be running on the Event Thread or with the Event lock to do this.

 

Search for resources to explain the Event Thread - there are a few. 

Developer
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

Re: connection problem, using Connector.open() ???

thnks a lot bro................ it worked Smiley Happy


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.