BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Newb Help??? - Uncaught Exception/ NoSuchFile.Java...? (http://www.blackberryforums.com/developer-forum/140254-newb-help-uncaught-exception-nosuchfile-java.html)

myworldntl 07-15-2008 08:43 AM

Newb Help??? - Uncaught Exception/ NoSuchFile.Java...?
 
Hi,

I'm new to blackberry development, and also to Java, so fun here... lol

Anyway, im trying to make a basic data entry page for now, i've not got as far as posting/saving the data yet, as i cant even get it to display on the simulator screen due to the following error(s)

--
'Uncaught exception thrown' displays as the JDE window Title, a load of:
'source code is not available'

Are repetivly displayed line after line in a 'NoSuchFile.Java' window within the JDE...

Also in the debug window, this message is shown:
'CodeStore.DependencyList.buildModuleDependencyLis t() took 10 - [16]'

And eventually, if i step though enough 'source code is not available' errors, then the following error is displayed on the simulators screen:

Uncaught Exception: java.lang.NullPointerException

Please see my code below, perhaps there is something very obvious wrong with it...??


Code:

/*
 * Main_File.java
 *
 * <your company here>, 2003-2005
 * Confidential and proprietary.
 */

package com.rim.samples.Simon_Test;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.i18n.*;



/*
 *
 *
 */
public class Lombard extends UiApplication
{
        public static void main(String[] args)
        {
                //create a new instance of the application
                //and start the application on the event thread
                Lombard app = new Lombard();
                app.enterEventDispatcher();
        }

        public Lombard()
        {
                //display a new screen
                pushScreen(new LombardScreen());
        }
}


final class LombardScreen extends MainScreen
{
//declare variables for later use


//Client Name
private AutoTextEditField clientNameText;
//Age (for sales margin)
private EditField ageValue;
//Gender (for sales margin)
private ObjectChoiceField genderChoice;
//Product name
private AutoTextEditField prodNameText;
//Name
private ObjectChoiceField partnerNameChoice;
//Name
private AutoTextEditField partnerNameText;
//Address
private AutoTextEditField addressText;
//Telephone Number
private AutoTextEditField telNumberText;
//Can the investment to be in Goldlist?
private ObjectChoiceField goldlistChoice;
//Broker Initial Commission
private EditField initialCommValue;
//Allocation Rate
private EditField allocationRateValue;
//Bid/Offer Spread
private EditField bidOfferSpreadValue;
//Guaranteed Administration Charge
private EditField adminChargeValue;
//Selected Months - Guaranteed Administration Charge
private EditField monthsAdminChargeValue;
//Underlying asset charges (e.g. on mutual fund)A
private EditField assestChargeAValue;
//Underlying asset charges (e.g. on mutual fund)B
private EditField assestChargeBValue;
//Renewal Commission
private EditField renCommissionValue;
//Investment Advisory Fee
private EditField AdFeeValue;
//Establishment Charge
private EditField estChargeValue;
//Selected Months - Establishment Charge
private EditField monthsEstChargeValue;
//Selected Premium/Fund - Establishment Charge
private ObjectChoiceField premfunEstChargeChoice;
//Policy Fee
private EditField policyFeeValue;
//Surrender penalty (value not year dependent)
private EditField surrPenValue;
//Selected Months - Surrender penalty (value not year dependent)
private EditField monthsSurrPenValue;
//Selected Premium/Fund - Surrender penalty (value not year dependent)
private ObjectChoiceField premfunSurrPenChoice;
//Surrender Penalty at end of year t
private EditField surrPenEoyValue;
//% of Premium - Surrender Penalty at end of year t
private EditField perOfPremiumSurrPenEoyValue;
//Trailer fee to LIA (for sales margin check):
private EditField trailerFeeValue;
//Premium
private EditField premiumValue;
//Premium Currency
private ObjectChoiceField currencyChoice;
//Premium Frequency
private ObjectChoiceField premFreqChoice;
//Premium Term (only for non-single premium)
private EditField premTermValue;
//Partial Surrenders (only for single premium policies)
private EditField partialSurrValue;
//Taken As - Partial Surrenders (only for single premium policies)
private ObjectChoiceField takenAsPartialSurrChoice;



public LombardScreen()
        {
                //invoke the MainScreen constructor
                //super();

                //add a screen title
                LabelField title = new LabelField("Lombard Client Illustration System - Version 2.6",
                                LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
                setTitle(title);
               
                LabelField header1 = new LabelField("Client Details");
                add(header1);

               
                //add a text label
                add(clientNameText);
                add(ageValue);
               
               
                String choices1[] = {"Male", "Female"};
                genderChoice = new ObjectChoiceField("Gender", choices1);
                add(genderChoice);
               
               
                LabelField header2 = new LabelField("Product Details");
                add(header2);
               

               
               
                //Product name
                add(prodNameText);

                LabelField header3 = new LabelField("IFA Details");
                add(header3);


                //Name
                String choices2[] = {"Partner 1", "Partner 2", "Partner 3", "Partner 4", "Partner 5", "Partner 6", "Partner 7", "Partner 8", "Partner 9", "Partner 10", "Partner 11", "Partner 12", "Partner 13", "Partner 14", "Other"};
                partnerNameChoice = new ObjectChoiceField("Name", choices2);
                                add(partnerNameChoice);
                //Name
                add(partnerNameText);
                //Address
                add(addressText);
                //Telephone Number
                add(telNumberText);

                LabelField header4 = new LabelField("Fund Details");
                add(header4);



                //Can the investment to be in Goldlist?
                String choices3[] = {"No", "Yes"};
                goldlistChoice = new ObjectChoiceField("Can the investment to be in Goldlist?", choices3);
                                add(goldlistChoice);
                               

                LabelField header5 = new LabelField("Charges");
                add(header5);
               
               
                //Broker Initial Commission
                add(initialCommValue);
                //Allocation Rate
                add(allocationRateValue);
                //Bid/Offer Spread
                add(bidOfferSpreadValue);
                //Guaranteed Administration Charge
                add(adminChargeValue);
                //Selected Months - Guaranteed Administration Charge
                add(monthsAdminChargeValue);
                //Underlying asset charges (e.g. on mutual fund)A
                add(assestChargeAValue);
                //Underlying asset charges (e.g. on mutual fund)B
                add(assestChargeBValue);
                //Renewal Commission
                add(renCommissionValue);
                //Investment Advisory Fee
                add(AdFeeValue);
                //Establishment Charge
                add(estChargeValue);
                //Selected Months - Establishment Charge
                add(monthsEstChargeValue);
               
                //Selected Premium/Fund - Establishment Charge
                String choices4[] = {"Premium", "Fund"};
                premfunEstChargeChoice = new ObjectChoiceField("Establishment Charge", choices4);
                add(premfunEstChargeChoice);
               
                //Policy Fee
                add(policyFeeValue);
                //Surrender penalty (value not year dependent)
                add(surrPenValue);
                //Selected Months - Surrender penalty (value not year dependent)
                add(monthsSurrPenValue);
               
                //Selected Premium/Fund - Surrender penalty (value not year dependent)
                String choices5[] = {"Premium", "Fund"};
                premfunSurrPenChoice = new ObjectChoiceField("Surrender penalty (value not year dependent)", choices5);
                add(premfunSurrPenChoice);
               
                //Surrender Penalty at end of year t
                add(surrPenEoyValue);
                //% of Premium - Surrender Penalty at end of year t
                add(perOfPremiumSurrPenEoyValue);
                //Trailer fee to LIA (for sales margin check):
                add(trailerFeeValue);


                LabelField header6 = new LabelField("Other Assumptions");
                add(header6);


                //Premium
                add(premiumValue);
               
                //Premium Currency
                String choices6[] = {"ARP", "ATS", "AUD", "BEF", "CAD", "CHF", "DEM", "DKK", "ESP", "EUR", "FIM", "GBP", "FRF", "GRD", "IEP", "ITL", "JPY", "LUF", "NLG", "NOK", "NZD", "PTE", "SEK", "USD", "ZAR"};
                currencyChoice = new ObjectChoiceField("Premium Currency", choices6);
                add(currencyChoice);

                //Premium Frequency
                String choices7[] = {"Single", "Monthly", "Quarterly", "Twice Yearly", "Annually"};
                premFreqChoice = new ObjectChoiceField("Premium Frequency", choices7);
                add(premFreqChoice);

               
                //Premium Term (only for non-single premium)
                add(premTermValue);
                //Partial Surrenders (only for single premium policies)
                add(partialSurrValue);
               
               
                //Taken As - Partial Surrenders (only for single premium policies)
                String choices8[] = {"Monthly", "Quarterly", "Twice Yearly", "Annually"};
                takenAsPartialSurrChoice = new ObjectChoiceField("", choices8);
                add(takenAsPartialSurrChoice);               
        }

        //override onClose() to display a dialog box
        //when the application is closed
        public boolean onClose()
        {
                Dialog.alert("Goodbye!");
                System.exit(0);
                return true;
                }

private MenuItem _closeItem = new MenuItem("Close", 200000, 10) {
                public void run()
                {
                        onClose();
                }
        };

        //override makeMenu to add the new menu items
        protected void makeMenu( Menu menu, int instance )
        {
                menu.add(_closeItem);
        }


}


hrbuckley 07-15-2008 11:39 AM

At first glance I don't see where you assign values to clientNameText or ageValue (BTW your comment style in your declaration section makes it very difficult to read, for me anyway) before you add() them to the screen. This could be the cause of the NullPointerException.

The reason the JDE/Debugger behave the way you describe is that the exception is thrown in the MainScreen (or some super class) for which you don't have debugging data. Since the exception is not caught in your app, the only other option for the JDE is to let the Java environment catch it by terminating your app, which wouldn't help you debug.

When you see that happen, somewhere in the JDE there should be a method call history. In the list of Calling Methods should be one of yours. If you select it the source screen will show you the file/line being executed when the exception was thrown.

goulamass 07-16-2008 02:39 AM

I think thaht hrbuckley is right.

Sometimes I have this kind of error and it allways when I try to add something null to the screen.

Check each variable you have

Ivanov 07-16-2008 02:58 AM

The Exception should be thrown at

add(clientNameText);

as you are adding null to the screen as goulmass and hrbuckley mentioned.
you have first to create instances of all your fields you want to add to the screen before adding them

myworldntl 07-16-2008 03:08 AM

Thanks
 
Hi,

Thanks everyone, double checked everything as suggested and seemed to get it working...

Main problem is i have no idea about java or the JDE atm, so it's very much a learning experience, lol.

Thanks for all your help though, now i just need to figure out how to get everything else to work that i want it to do, lol, but I need to walk before i can run right, ha ha :D

Anyhow, this is the updated code which now works, and thanks again.

Code:

package com.rim.samples.Simon_Test;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.i18n.*;



public class Lombard extends UiApplication
{
        public static void main(String[] args)
        {
                Lombard app = new Lombard();
                app.enterEventDispatcher();
        }

        public Lombard()
        {
                pushScreen(new LombardScreen());
        }
}


final class LombardScreen extends MainScreen
{
//Gender (for sales margin)
private ObjectChoiceField genderChoice;

//Name
private ObjectChoiceField partnerNameChoice;

//Can the investment to be in Goldlist?
private ObjectChoiceField goldlistChoice;

//Selected Premium/Fund - Establishment Charge
private ObjectChoiceField premfunEstChargeChoice;

//Selected Premium/Fund - Surrender penalty (value not year dependent)
private ObjectChoiceField premfunSurrPenChoice;

//Premium Currency
private ObjectChoiceField currencyChoice;

//Premium Frequency
private ObjectChoiceField premFreqChoice;

//Taken As - Partial Surrenders (only for single premium policies)
private ObjectChoiceField takenAsPartialSurrChoice;





public LombardScreen()
        {
                super();

                LabelField title = new LabelField("Lombard Demo", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
                setTitle(title);
               
                LabelField header1 = new LabelField("Client Details: -", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
                add(header1);
               
                //Seperator
                SeparatorField myLine = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(myLine);

                //Client Name
                AutoTextEditField clientNameText = new AutoTextEditField("Client Name: ", "");
                add(clientNameText);                             
               
                //Age
                EditField ageValue = new EditField("Age: ", "");
                add(ageValue);
               
                //Gender
                String choices1[] = {"Male", "Female"};
                genderChoice = new ObjectChoiceField("Gender", choices1);
                add(genderChoice);
               
                //HEADER & Seperators - Product Details
                SeparatorField header2Top = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header2Top);
                LabelField header2 = new LabelField("Product Details: -");
                add(header2);
                SeparatorField header2Bot = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header2Bot);
               
               
                //Product name
                AutoTextEditField prodNameText = new AutoTextEditField("Product name: ", "");
                add(prodNameText);

                //HEADER & Seperators - IFA Details
                SeparatorField header3Top = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header3Top);
                LabelField header3 = new LabelField("IFA Details: -");
                add(header3);
                SeparatorField header3Bot = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header3Bot);

                //Name
                String choices2[] = {"Partner 1", "Partner 2", "Partner 3", "Partner 4", "Partner 5", "Partner 6", "Partner 7", "Partner 8", "Partner 9", "Partner 10", "Partner 11", "Partner 12", "Partner 13", "Partner 14", "Other"};
                partnerNameChoice = new ObjectChoiceField("Name", choices2);
                                add(partnerNameChoice);
                //Name
                AutoTextEditField partnerNameText = new AutoTextEditField("Name: ", "");
                add(partnerNameText);
               
                //Address
                AutoTextEditField addressText = new AutoTextEditField("Address: ", "");
                add(addressText);
               
                //Telephone Number
                BasicEditField telNumberText = new AutoTextEditField("Telephone Number: ", "");
                add(telNumberText);

                //HEADER & Seperators - Fund Details
                SeparatorField header4Top = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header4Top);
                LabelField header4 = new LabelField("Fund Details: -");
                add(header4);
                SeparatorField header4Bot = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header4Bot);


                //Can the investment to be in Goldlist?
                String choices3[] = {"No", "Yes"};
                goldlistChoice = new ObjectChoiceField("Can invest in Goldlist?", choices3);
                                add(goldlistChoice);
               
                //HEADER & Seperators - Charges
                SeparatorField header5Top = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header5Top);
                LabelField header5 = new LabelField("Charges: -");
                add(header5);
                SeparatorField header5Bot = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header5Bot);               
               
                //Broker Initial Commission
                EditField initialCommValue = new EditField("Broker Initial Commission: ", "");
                add(initialCommValue);
               
                //Allocation Rate
                EditField allocationRateValue = new EditField("Allocation Rate: ", "");
                add(allocationRateValue);
               
                //Bid/Offer Spread
                EditField bidOfferSpreadValue = new EditField("Bid/Offer Spread: ", "");
                add(bidOfferSpreadValue);
               
                //Guaranteed Administration Charge
                EditField adminChargeValue = new EditField("Guaranteed Administration Charge: ", "");
                add(adminChargeValue);
               
                //Selected Months - Guaranteed Administration Charge
                EditField monthsAdminChargeValue = new EditField("Guaranteed Administration Charge: ", "");
                add(monthsAdminChargeValue);
               
                //Underlying asset charges (e.g. on mutual fund)A
                EditField assestChargeAValue = new EditField("Underlying asset charges (e.g. on mutual fund)A: ", "");
                add(assestChargeAValue);
               
                //Underlying asset charges (e.g. on mutual fund)B
                EditField assestChargeBValue = new EditField("Underlying asset charges (e.g. on mutual fund)B: ", "");
                add(assestChargeBValue);
               
                //Renewal Commission
                EditField renCommissionValue = new EditField("Renewal Commission: ", "");
                add(renCommissionValue);
               
                //Investment Advisory Fee
                EditField AdFeeValue = new EditField("Investment Advisory Fee: ", "");
                add(AdFeeValue);
               
                //Establishment Charge
                EditField estChargeValue = new EditField("Establishment Charge: ", "");
                add(estChargeValue);
               
                //Selected Months - Establishment Charge
                EditField monthsEstChargeValue = new EditField("Establishment Charge: ", "");
                add(monthsEstChargeValue);
               
                //Selected Premium/Fund - Establishment Charge
                String choices4[] = {"Premium", "Fund"};
                premfunEstChargeChoice = new ObjectChoiceField("Establishment Charge", choices4);
                add(premfunEstChargeChoice);
               
                //Policy Fee
                EditField policyFeeValue = new EditField("Policy Fee: ", "");
                add(policyFeeValue);
               
                //Surrender penalty (value not year dependent)
                EditField surrPenValue = new EditField("Surrender penalty (value not year dependent): ", "");
                add(surrPenValue);
               
                //Selected Months - Surrender penalty (value not year dependent)
                EditField monthsSurrPenValue = new EditField("Surrender penalty (value not year dependent): ", "");
                add(monthsSurrPenValue);
               
                //Selected Premium/Fund - Surrender penalty (value not year dependent)
                String choices5[] = {"Premium", "Fund"};
                premfunSurrPenChoice = new ObjectChoiceField("Surrender penalty (value not year dependent)", choices5);
                add(premfunSurrPenChoice);
               
                //Surrender Penalty at end of year t
                EditField surrPenEoyValue = new EditField("Surrender Penalty at end of year t: ", "");
                add(surrPenEoyValue);
               
                //% of Premium - Surrender Penalty at end of year t
                EditField perOfPremiumSurrPenEoyValue = new EditField("Surrender Penalty at end of year t: ", "");
                add(perOfPremiumSurrPenEoyValue);
               
                //Trailer fee to LIA (for sales margin check):
                EditField trailerFeeValue = new EditField("Trailer fee to LIA (for sales margin check): ", "");
                add(trailerFeeValue);

                //HEADER & Seperators - Other Assumptions
                SeparatorField header6Top = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header6Top);
                LabelField header6 = new LabelField("Other Assumptions: -");
                add(header6);
                SeparatorField header6Bot = new SeparatorField(SeparatorField.LINE_HORIZONTAL);
                add(header6Bot);

                //Premium
                EditField premiumValue = new EditField("Premium: ", "");
                add(premiumValue);
               
                //Premium Currency
                String choices6[] = {"ARP", "ATS", "AUD", "BEF", "CAD", "CHF", "DEM", "DKK", "ESP", "EUR", "FIM", "GBP", "FRF", "GRD", "IEP", "ITL", "JPY", "LUF", "NLG", "NOK", "NZD", "PTE", "SEK", "USD", "ZAR"};
                currencyChoice = new ObjectChoiceField("Premium Currency", choices6);
                add(currencyChoice);

                //Premium Frequency
                String choices7[] = {"Single", "Monthly", "Quarterly", "Twice Yearly", "Annually"};
                premFreqChoice = new ObjectChoiceField("Premium Frequency", choices7);
                add(premFreqChoice);

               
                //Premium Term (only for non-single premium)
                EditField premTermValue = new EditField("Premium Term (only for non-single premium): ", "");
                add(premTermValue);
               
                //Partial Surrenders (only for single premium policies)
                EditField partialSurrValue = new EditField("Partial Surrenders (only for single premium policies): ", "");
                add(partialSurrValue);
               
               
                //Taken As - Partial Surrenders (only for single premium policies)
                String choices8[] = {"Monthly", "Quarterly", "Twice Yearly", "Annually"};
                takenAsPartialSurrChoice = new ObjectChoiceField("", choices8);
                add(takenAsPartialSurrChoice);               
        }

        //override onClose() to display a dialog box when the application is closed
        public boolean onClose()
        {
                Dialog.alert("Goodbye!");
                System.exit(0);
                return true;
                }

private MenuItem _closeItem = new MenuItem("Close", 200000, 10) {
                public void run()
                {
                        onClose();
                }
        };

        //override makeMenu to add the new menu items
        protected void makeMenu( Menu menu, int instance )
        {
                menu.add(_closeItem);
        }


}



All times are GMT -5. The time now is 01:44 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.