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

New Member
Posts: 1
Registered: ‎04-01-2010
My Device: 9700
My Carrier: WIND Hellas

Http connections using JDE5

I installed JDE5 and I'm trying to open an HTTP connection. Here's the code snippet:


try {            
    ConnectionFactory connFact = new ConnectionFactory();    
    TransportDescriptor[] transports = TransportInfo.getAvailableTransports();
    message( "Available transports: " + transports.length );    
    for ( int i = 0; i < transports.length; i++ ) {
        TransportDescriptor t = transports[ i ];
        int type = t.getTransportType();
        boolean hasCoverage = TransportInfo.hasSufficientCoverage( type );        
        message( "Type: " + TransportInfo.getTransportTypeName( type ) );
        message( "Coverage: " + hasCoverage );
        message( "Cid: " + t.getCid() );
        message( "Uid: " + t.getUid() );
        message( "\n" );

    ConnectionDescriptor connDesc;
    message("Attempting to get connection, timeout: " + connFact.getConnectionTimeout() );
    connDesc = connFact.getConnection("http://myserver.gr");    
    message("Got connection");
    HttpConnection httpConn;
    if (connDesc != null) {
        httpConn = (HttpConnection) connDesc.getConnection();
        final int code = httpConn.getResponseCode();
        message("Code: " + code);
    } else {
        message("No connection");
} catch (Exception e) {
    message("Exception: " + e.getClass().toString() + " -> " + e.getMessage());


When I run the app, I see something like this:


Available transports: 3

Type: WAP

Coverage: true

Cid: WAP

Uid: timgr WAPtrans


Type: BISB

Coverage: true

Cid: blahblah

Uid: blahblah


Type: TCP Cellular

Coverage: true

Cid: null

Uid: null


Attempting to get connection, timeout: 0

Got connection

Exception: class



Apparently the exception is thrown when getReponseCode() is called.

Any idea what causes this exception?


Furthermore, when I try to explicitly specify transport type as TransportInfo.TRANSPORT_BIS_B (with the appropriate UID), getConnection() returns null. Why would that be?


Note that I have signed the app (even though it says it's not required) and I have granted it Trusted App status.


Many thanks.