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
Posts: 7
Registered: ‎09-22-2009
My Device: Not Specified

uncaught NullPointerException when starting App in simulator

[ Edited ]

BlackBerry 9000. V4.6.0.162 (Platform 4.0.0.155)

Eclipse blackberry JDE component package 4.6.1

Simulator version 4.6.0.190

 

I can run the application in device but when I run it in simulator, it just prints:

 

Starting AMSMTM

Started AMSMTM(190)

Foreground AMSMTM(190)

 

Then stops. The application UI does not show up, The simulator hang.   AMSMTM is my app name.

 

Simulator shows "JVM error 104 uncaught NullPointerException"

 

I set a breakpoint at the first statement in main, it doesn't get hit.

 

I don't know why there is a nullpointerException, I don't think it is from my app because I can run it in device and it works.

 

Thanks!

 

 

 

 

Message Edited by kcheng86 on 09-25-2009 06:02 PM
Developer
Posts: 220
Registered: ‎09-09-2008
My Device: Bold 9780
My Carrier: Telstra AU

Re: uncaught NullPointerException when starting App in simulator

Hi

 

Does your main class look like this :

 

 

public void MyClass extends UiApplication{public static void main(String args[]){ MyCalss myClass = new MyCalss(); myClass.enterEventDispatcher();}public MyClass(){ pushScreen(new FirstScreen());}}

 

 Your FirstScreen of course should then be extended to MainScreen or Screen.

 

-----------

Follow me on twitter: twitter.com/paul.haenel

If your issue is resolved, please mark this thread as solved.

Set the "Solution" mark on the post which contains the answer to your question.
New Developer
Posts: 7
Registered: ‎09-22-2009
My Device: Not Specified

Re: uncaught NullPointerException when starting App in simulator

Yes, it looks similar to that.  It used to work in simulator, I kept adding coding to it and tested it with device and it works. After a while when I run it in simulator again, it stoped working.   The thing is I put a breakpoint at the first line

MyCalss myClass = new MyCalss();

 

it still doesn't get hit.

Developer
Posts: 220
Registered: ‎09-09-2008
My Device: Bold 9780
My Carrier: Telstra AU

Re: uncaught NullPointerException when starting App in simulator

Have you tried to reset / clean you simulator ?

 

Paul 

-----------

Follow me on twitter: twitter.com/paul.haenel

If your issue is resolved, please mark this thread as solved.

Set the "Solution" mark on the post which contains the answer to your question.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: uncaught NullPointerException when starting App in simulator

There is a problem in this code isn't there?

 

public void MyClass extends UiApplication{

public static void main(String args[]){

   MyCalss myClass = new MyCalss();

   myClass.enterEventDispatcher();

}

public MyClass(){   pushScreen(new FirstScreen());}}

 

Look at: 

MyCalss myClass = new MyCalss();

 

Shouldn't this be

MyClass myClass = new MyClass();

 

What is MyCalss?

Developer
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: uncaught NullPointerException when starting App in simulator

I think it is just a typo.
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: uncaught NullPointerException when starting App in simulator

Wrap your enterEventDispatcher() in a try/catch block, and catch Throwable.

 

Catching Throwable forces the system to log a full stack trace along with the exception. You can then retreive the event log from the device using javaloader, or view the event log on the device by using the <alt> L G L G key sequence from the home screen.

 

 

Highlighted
Developer
Posts: 80
Registered: ‎09-12-2009
My Device: Bold 9700
My Carrier: Vodafone UK

Re: uncaught NullPointerException when starting App in simulator

Have u tried running the Simulator in debug mode on Eclipse?

 

I have a strong feeling that the NullPointer is being thrown in the MyClass Constructor.

 

Look through carefully and insure you have initialized  all your variables that are in use.

 

I have many wasted hours figuring out  that I forgot to call new Hashtable() or something silly. Smiley Frustrated

Genius Development Scotland
Website: http://www.genius-dev.co.uk
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: uncaught NullPointerException when starting App in simulator

Hi,

 

are you using any image ,and if yes have you added that into your project.Add the resource by right clicking on the project and selecting the file.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
New Developer
Posts: 7
Registered: ‎09-22-2009
My Device: Not Specified

Re: uncaught NullPointerException when starting App in simulator

It turned out to be that on simulator the application cannot find some file and therefore cause somethings to be uninitialized.

 

I fixed that but the breakpoints still don't get hit in simulator.

 

 

Thanks guys.