Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    6

    Exclamation Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Hello,

    I am using MIDP 2.0 & CDC 1.0 to develop a J2ME application that created record store to save data. I want these stores to be shared cause I want to update the data through another application.

    I create record stores successfully, but once I use the setMode method with the RecordStore.AUTHMODE_ANY option, it throws NullPointerException.

    I don't know what is needed to stop this exception; do I need to make my application signed? Is it a security issue? I am not sure.

    It works fine using Sun emulator. But when I try to make it work on a Nokia 7610, it throws the NullPointerException.

    Here is the code that simulates the problem:

    package test;


    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;


    public class DBTestMidlet extends MIDlet {

    private Display display;
    RecordStore store;

    public DBTestMidlet() {
    display = Display.getDisplay(this);

    // Create a record store
    int authMode = RecordStore.AUTHMODE_ANY;
    boolean writable = true;

    try {
    store = RecordStore.openRecordStore("TestStore", true);
    store.setMode(authMode, writable);
    //store = RecordStore.openRecordStore("TestStore", true, authMode, writable);
    display.setCurrent(new TextBox("Success", "The database was created successfully!!", 60000, TextField.ANY));

    } catch (Exception e) {
    // couldn't open it or create it
    display.setCurrent(new TextBox("Error", e.toString(), 60000, TextField.ANY));
    }
    }

    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    System.out.println("Destroy is here ");

    try {
    store.closeRecordStore();
    RecordStore.deleteRecordStore("TestStore");
    System.out.println("TestStore Destroyed!");

    } catch (RecordStoreNotFoundException e) {
    // no such record store
    e.printStackTrace();

    } catch (RecordStoreNotOpenException e) {
    e.printStackTrace();

    } catch (RecordStoreException e) {
    // somebody has it open
    e.printStackTrace();
    }

    }
    }
    Hope you can help me solve this problem. Thanks

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Hello sgaber,

    some questions regarding:

    1)
    I am using MIDP 2.0 & CDC 1.0 to develop a J2ME application
    Just to check: do you mean CDLC 1.0 (which is the config for Nokia 7610)?

    2) What happens if you use RecordStore.AUTHMODE_PRIVATE as instead of RecordStore.AUTHMODE_ANY?


    I quickly tested this with my N93, no problems there (prompting "The database was created successfully!!").

    How about trying a solution as defined within the following discussion:
    http://discussion.forum.nokia.com/fo...ad.php?t=44018


    Regards,
    r2j7

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    6

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    1- Yes, I meant CLDC 1.0 - sorry for this mistake.

    2- If I use RecordStore.AUTHMODE_PRIVATE, it works fine - once I switch to RecordStore.AUTHMODE_ANY, it fails

    3- Regarding the solution posted in the link you mentioned - I don't know how it is related to my issue? They talk about record store size - not sharing.

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Based on your answer to the second question, this could be some security-related issue which at times appear especially with operator-branded phones. Is your Nokia 7610 an operator-branded phone?

    (The third issue included some workaround of closing record stores before opening any, I don't know if it works with your issue since I haven't had an opportunity to test it.)

    Regards,
    r2j7

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    6

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    My phone isn't an operator branded phone. I also tried this on Nokia 9300 & gave the same Null Pointer Exception.

    I started to suspect that the share doesn't work with CLDS 1.0 since I downloaded Nokia S60 Third Edition Emulator & it worked fine (but it is configured to use MIDP 2 & CLDC 1.1). Do you know if this is correct or not?

    Do you have any way to debug or see the stack trace of this exception on the mobile - so that I can see what is the reason for this Null Pointer Exception?

    Regarding point 3, I even tried to close the recordstore and then open it & set the mode - but this also failed

  6. #6
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Hello sgaber,

    I've tested this issue with with Nokia 6680 (S60 2nd Ed. FP2 phone, MIDP 2.0 + CLDC 1.1). With RecordStore.AUTHMODE_ANY java.lang.NullPointerException:0 was thrown (whereas with RecordStore.AUTHMODE_PRIVATE not) as you've suggested.

    All in all this appears to exist with older phones, and I doubt there will be sw updates for this. You previously suggested whether this is a security issue: I wonder if signing the app would make a difference? I'll have tomorrow possibility to test this further, if you've have a certificate issued by certificate provider you could test this too. For S60 2nd Ed. phones (Nokia 7610), there's also a self-signing "option":

    http://wiki.forum.nokia.com/index.ph...es_for_MIDlets

    Regards,
    r2j7

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    6

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Hello r2j7,

    Thanks for your help so far - you now have the same issue as I had
    Regarding the self-signing, can you please send me a link that explains this in more details since I am new to this thing & didn't understand how to follow the steps explained in the link you provided?

    Thanks again for your help.

  8. #8
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,430

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Here is a link on a previous discussion on Signing in S60 2nd edition phones.
    http://discussion.forum.nokia.com/fo...ad.php?t=42411

    Hope this helps!

    Regards
    Gopal

  9. #9
    Registered User
    Join Date
    Dec 2007
    Posts
    6

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    I have signed the midlte using the info provided in the link mentioned in the previous reply & I was able to install the midlet as trusted third party application. But still the share didn't work it still throws the Null Pointer Exception.

    Do you know if this is a known issue with Nokia 7610? Is the record store share supported by such phones?

  10. #10
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Hello sgaber,

    pardon me for being late with this issue.

    I've continued testing, I signed the app with VeriSign but to no avail: my result was still the same as yours, NullPointerException.

    Could you test if there's difference when first setting the authMode to private, then after RecordStore creation you change it with setMode() as follows:

    Code:
     
            int authMode = RecordStore.AUTHMODE_PRIVATE;
            boolean writable = true;
            
            try {
                //store = RecordStore.openRecordStore("TestStore", true);
                //store.setMode(authMode, writable);
                store = RecordStore.openRecordStore("TestStore", true, authMode, writable);
                if(store!=null)
                display.setCurrent(new TextBox("Success", "The database was created successfully!!", 60000, TextField.ANY));
                store.setMode(RecordStore.AUTHMODE_ANY, writable);
                display.setCurrent(new TextBox("Success", "The mode was changed!!", 60000, TextField.ANY));
    
                
            }
    (I've tested this but to no avail, no change there with NullPointerException)

    Regards,
    r2j7

  11. #11
    Registered User
    Join Date
    Dec 2007
    Posts
    6

    Re: Using RecordStore.AUTHMODE_ANY throws NullPointerException

    Hello r2j7,
    I tried it but it also gave me Null Pointer Exception
    What else can I try? Or it is a bug & I need to think of a work-around for it?

    Thanks for your help.

Similar Threads

  1. calling midlet from midlet throws SecurityException on 6600
    By brianpegan in forum Mobile Java General
    Replies: 3
    Last Post: 2010-10-25, 05:31
  2. recordcontrol.setStream(out) throws NullPointerException
    By bharatdevada in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2006-11-10, 02:16
  3. Replies: 2
    Last Post: 2004-11-17, 11:20
  4. What can we learn from this ?
    By dtianx in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2004-04-28, 03:45
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×