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

java.lang.StringIndexOfBoundsException: String index out of range: 2 thrown by Connector.open()

by BlackBerry Development Advisor ‎02-16-2010 11:32 AM - edited ‎09-16-2010 02:31 PM (1,220 Views)

Summary

 

This article applies to the following:

  • BlackBerry® Device Software 4.3

 

Details

 

Problem

 

Opening a port on the BlackBerry smartphone to listen for incoming connections may throw the following exception:

 

    java.lang.StringIndexOfBoundsException: String index out of range: 2

 

The following are examples of calls to Connector.open(String url):

 

 

Connector.open(“http//:”+port)
Connector.open(“sms//:”+port);

Cause

 

The BlackBerry smartphone firewall check is failing because it is trying to check the hostname, which does not exist in such URLs.

Workaround

 

To work around this issue, change the application permission for Connections to Allow so that the firewall does not attempt to check the hostname. Application permissions can be set in one of the following ways:

  • Programmatically — For more information see this article
  • By setting Application Control Policy — Refer to this article for more information

This issue was resolved in BlackBerry Device Software 4.5 and later.

 

 

 

 

Contributors
Users Online
Currently online: 12 members 1,156 guests
Please welcome our newest community members: