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
New Developer
amj_wind
Posts: 28
Registered: ‎07-17-2008
My Device: Not Specified

ClassCastException on MapField class instantiation

Hi -

 

I am getting a ClassCastException on : map = new MapField(). This is on real hardware 8820, v4.5.0.52. It

runs fine on the simulator 8820, v4.5.0.44.

 

Since this class needs signing, I have gone through the process of getting the keys and signing the app. This is my first

time, and I could have done something incorrect in the signing. The signing tool says that it is signed.

 

Do I need to synch up on xx in the 4.5.0.xx? If so, is there a place for the release notes? I downloaded the

JDE from the official website, and it comes with 4.5.0.44. How do I get to 4.5.0.52 on the simulator?

 

Any other ideas would be appreciated as well.

Thanks

amod

 

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,429
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: ClassCastException on MapField class instantiation

I haven't been able to reproduce this.  Can you provide a larger code snippet that triggers the exception?
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
Please use plain text.
New Developer
amj_wind
Posts: 28
Registered: ‎07-17-2008
My Device: Not Specified

Re: ClassCastException on MapField class instantiation

Sure.  I have removed some of the other code for clarity.

I am getting the exception in the catch block.

 

Did you run on the real hardware or the emulator? This works on the emulator, but

throws the exception on the hardware.

Thanks

amod 

 

1) Entry -

package com.mobigility;

 

import net.rim.device.api.ui.UiApplication;

 

public class Parkido extends UiApplication{

/**

* Sets up an instance of this class as the event dispatching thread.

 *

* @param args Not used.

*/

 public static void main(String[] args)

{

new Parkido().enterEventDispatcher();

}

 

/**

* Loads the application screen.

*/

Parkido()

{

pushScreen(
new ParkidoScreen());

}

}

 

2) ParkidoScreen.java:

package com.mobigility;

 

import java.util.*;

 

import javax.microedition.location.Coordinates;

import net.rim.device.api.ui.container.MainScreen;

import net.rim.device.api.ui.UiApplication;

import net.rim.device.api.ui.component.*;

import net.rim.device.api.ui.XYPoint;

import net.rim.device.api.lbs.MapField;

 

 

public class ParkidoScreen extends MainScreen {

 

/***************************************************************************

* Members

 *

*/

MapField map; // Map instance that will be pushed on foreground

Vector vecGPSCoordinates; // GPS simulated coordinates

static Vector vecSM; // SM vectors

 

final int NUMPOINTS = 17; // Number of points that are simulated

final static int NUMSM = 2; // Number of points that are simulated

final int PERIOD = 2000; // Ring the timer every PERIOD time

final int ZOOM = 2; // Set the level for map view.

 static int indexCoordinate;String sEx="deadbeef";

 

/***************************************************************************

* Constructor

 *

*/

ParkidoScreen() {

 

try {

// Instantiate the MapField object

//

map = new MapField();

} catch (Exception ex) {

 

setException(ex);

UiApplication.getUiApplication().invokeLater(
new Runnable() {

public void run() {Dialog.alert(

"Exception in ParkidoScreen().Bailing ." +getException());

System.exit(1);

}

});

}

 

}

Please use plain text.
Administrator
MSohm
Posts: 14,429
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: ClassCastException on MapField class instantiation

I did tested this on an actual BlackBerry, not just the BlackBerry Simulator.

 

I created a simple test application that just pushes the screen you have below and I didn't receive any exception.  Is there more to your application that triggers the exception? 

 

What are the version numbers of the following modules on the BlackBerry.  You can see these by going to Options, Advanced Options, Applications and selecting View Modules from the menu.

 

net_rim_bb_lbs

net_rim_bb_lbs_api

net_rim_bb_lbs_api_2

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
Please use plain text.
New Developer
amj_wind
Posts: 28
Registered: ‎07-17-2008
My Device: Not Specified

Re: ClassCastException on MapField class instantiation

There is more code in the application, but I started commenting to a point

where the instatiation of the MapField class throws an exception.

 

Here are the versions:

net_rim_bb_lbs - 1.2.26

net_rim_bb_lbs_api - 1.2.26

net_rim_bb_lbs_api_2 - 4.5.0.52

 

What do they show up on your BB?

Thanks

amod

Please use plain text.
Administrator
MSohm
Posts: 14,429
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: ClassCastException on MapField class instantiation

Those values are fine and are the same as mine.  They should match the BlackBerry handheld software version in 4.5.0.

 

Have you been able to reproduce this in a stripped down sample application that just pushes the screen you have posted?  Or does this only occur in a larger application?

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
Please use plain text.
New Developer
amj_wind
Posts: 28
Registered: ‎07-17-2008
My Device: Not Specified

Re: ClassCastException on MapField class instantiation

I will build a new project and try just that tonite. Earlier, I was commenting the larger project.

Any other suggestion to try out?

Thanks

amod

Please use plain text.
Administrator
MSohm
Posts: 14,429
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: ClassCastException on MapField class instantiation

You could try to store the value returned from the new MapField call in an Object, then call getClass and getName on it to see what is being returned.
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
Please use plain text.
New Developer
amj_wind
Posts: 28
Registered: ‎07-17-2008
My Device: Not Specified

Re: ClassCastException on MapField class instantiation

1) I built a new project, and I still see the same exception.

2) I then tried to print the returned class, but I still see the Exception.

 

As before, both work well in the emulator.

 

I am lost, and I can to reinstall the device software. Can you point me to the location for a stable 4.5.0 release?

If there is anything else, let me know.

Thanks

amod

 

Here is the code of the new project -

Parkido.java:

=========

package com.mobigility;

 

import net.rim.device.api.ui.UiApplication;

 

 

public class Parkido extends UiApplication{

/**

* Sets up an instance of this class as the event dispatching thread.

 *

* @param args Not used.

*/

 public static void main(String[] args)

{

new Parkido().enterEventDispatcher();

}

 

/**

* Loads the application screen.

*/

Parkido()

{

pushScreen(
new ParkidoScreen());

}

}

 

ParkidoScreen.java:

==============

package com.mobigility;

import java.util.*;

import javax.microedition.location.Coordinates;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.XYPoint;
import net.rim.device.api.lbs.MapField;

public class ParkidoScreen extends MainScreen {

 /***************************************************************************
  * Members
  *
  */
// MapField map;   // Map instance that will be pushed on foreground
 String sEx="deadbeef";

 /***************************************************************************
  * Constructor
  *
  */
 ParkidoScreen() {

  try {
   // Instantiate the derived MapField object
   //
   Object o = new MapField();
   setException(o.getClass().getName());
   UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {     
     Dialog.alert("Class name of object " +getException());
     System.exit(1);
    }
   });
   
  } catch (Exception ex) {
   
   setException(ex.toString());
   UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
     Dialog.alert("Exception in ParkidoScreen().Bailing out ." +getException());
     System.exit(1);
    }
   });
  }

 }

 /* For exception handling
  */
 private String getException(){
  return sEx;
 }
 private void setException(String strEx){
  sEx=strEx;
 }
 

}

Please use plain text.
New Developer
amj_wind
Posts: 28
Registered: ‎07-17-2008
My Device: Not Specified

Re: ClassCastException on MapField class instantiation

I just realised that my desktop manager version is 4.5.0.15. Does that need to be in synch with the device

software version of 4.5.0.52? If so, where should I get that desktop manager version?

Please use plain text.