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

Reply
Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified
Accepted Solution

java.lang.Error on Wi-Fi connection

 

sock=(SocketConnection)Connector.open("socket://"+gatewayList[gwIndex]+";interface=wifi");

Whenever the above line is run,my device crashes with an uncaught error. The server address and port are correct because I've managed to connect with the "GPRS" on the simulator, with or without MDS.

 

 

Device platform 4.3.072

JDE version 4.5.0 (can this be the problem?)

Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified

Re: java.lang.Error on Wi-Fi connection

[ Edited ]

I've tried:

1) downgraded my JDE to 4.3.0

2) appending ;deviceside=true

 

Note: I have no SIM card in my device

 

Please help Smiley Sad

 

 

JDE 4.3.0

Application version: 4.3.072

Platform version 2.6.043

Message Edited by KeniF on 09-15-2008 12:50 PM
Message Edited by KeniF on 09-15-2008 12:56 PM
BlackBerry Development Advisor
Posts: 15,302
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: java.lang.Error on Wi-Fi connection

What type of exception is being thrown and what are its .toString details?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: java.lang.Error on Wi-Fi connection

Yeah, even if the URI was incorrect you shouldn't be getting an Error on it...  Hm.  If you could post your entire connection block I'll give it a shot here and see if I can repro.

Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified

Re: java.lang.Error on Wi-Fi connection

[ Edited ]

Cant toString() the error as I can only do wi-fi on the actual device, and the error is a sudden pop-up which says:

Uncaught Exception: java.io.Error

if(WLANInfo.getWLANState()==WLANInfo.WLAN_STATE_CONNECTED){
try{
invokeGUI();
sock=(SocketConnection)Connector.open("socket://"+gatewayList[gwIndex]+";interface=wifi");
gtp=new GTP(sock); //only copies the sock in constructor if(!gtp.attemptConnection()){
throw new Exception();
}//if connection failed

------------------------------------
private void invokeGUI(){
if(smg!=null&&smg.isForeground()){ //smg is a UiApplication
smg.invokeAndWait(new Runnable(){
public void run(){
smg.updateStatus(currentState,techInUse);
}//run
});//Runnable
} //if
}//invokeGUI

//in GTP.attemptConnection()
public boolean attemptConnection() throws Exception{
boolean result=false;
try{
in=sock.openDataInputStream();
out=sock.openDataOutputStream();
result=true;
}//try
catch(Exception e){
//already using a boolean
}//catch
finally{ return result; }
}//attemptConnection

Message Edited by KeniF on 09-15-2008 06:31 PM
Developer
Posts: 19,633
Registered: ‎07-14-2008
My Device: Not Specified

Re: java.lang.Error on Wi-Fi connection

If you are not catching the Exception (as it would appear by the Popup) check your Exception log (ALT LGLG) and you should see the Exception in there (in Bold).  That should give you the toString and the stack trace too.  At least I hope so.

 

What device are you using? I presume an 8120 based on the fact it is WiFi and 4.3.

Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified

Re: java.lang.Error on Wi-Fi connection

[ Edited ]

Name: Error

Severity: Severe Error

No detail message

 

the stack trace is:
MyProgram BackgroundThread run

net_rim_cldc-2 Connector open

net_rim_cldc-13 RIMConnector open

net_rim_cldc-13 RIMConnector <private>

net_rim_os-4 Protocol openPrim

net_rim_cldc-2 Connector open

net_rim_cldc-13 RIMConnector open

net_rim_cldc-13 RIMConnector <private>

net_rim_cldc_io_tcp Protocol openPrim

net_rim_cldc_io_tcp TcpConnectionFactory getConnection

net_rim_cldc_io_tcp Protocol init

net_rim_cldc_io_tcp Protocol <private>

net_rim_cldc-12 EventThreadCheck <clinit>

net_rim_cldc-5 Application getApplication

 

 

Is it because I didn't catch the IOException? I thought catching an Exception will cover everything :0

 

And it's a 8120 Pearl, you're right Smiley Happy Thanks for the help so far...

Message Edited by KeniF on 09-15-2008 10:25 PM
Message Edited by KeniF on 09-15-2008 10:28 PM
Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: java.lang.Error on Wi-Fi connection

I'm still unclear as to whether this is a java.lang.Error or an Exception - the former would be more indicative of a lower-level problem, the latter of a more simple user issue.  Eh, anyway...  I couldn't reproduce anything.  The below code worked fine on my 8120 4.3.0.115.

 

 

if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) { try { SocketConnection sock = (SocketConnection) Connector.open("socket://www.mobiyana.com:80;interface=wifi"); DataInputStream in = sock.openDataInputStream(); DataOutputStream out = sock.openDataOutputStream(); add(new RichTextField("got it")); } catch (IOException e) { add(new RichTextField("exception = " + e.toString())); } }

 

 

 

Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified

Re: java.lang.Error on Wi-Fi connection

Yes it's definitely an Error as I've managed to catch it.

However, it seems there's a problem with the device, not the code because even this

 

sock=(SocketConnection) Connector.open("socket://www.mobiyana.com:80");

 doesn't work!

 

 

Maybe it happens when no SIM card is inserted. Will update you when my company SIM card arrives...

 

if(!SIM)

  throw java.io.Error?

Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: java.lang.Error on Wi-Fi connection

No, that wouldn't be it because I don't have a SIM in the 8120 I tested on.  I flipped some bits here and there on the device and kept re-running the little test app and it either worked or didn't work, but I never got any Errors.  Kind of at a loss...  You've got Wifi all set up on an access point, etc?  Does your browser work over Wifi?