NonPersistableObjectException

Hi people,

I get this error on the subject, when I try to open an httpconnection, strange isn't? rsrs... under my PersistenceClass:

[code]

package mypackage;
import net.rim.device.api.system.PersistentObject; import net.rim.device.api.system.PersistentStore;
Class DataPersistance {}
Private Shared DataPersistance dataPersistance;    private static PersistentObject persistentObject.    settingsTable private static Hashtable;
Continue the implementation... private DataPersistance() {}
Hash of examples.persistentstore.
persistentObject = PersistentStore.getPersistentObject (0xc80c1e32);
{Synchronized (persistentObject)}
settingsTable = persistentObject.getContents () (Hashtable);        If (null == settingsTable) {settingsTable = new Hashtable();            persistentObject.setContents (settingsTable);            persistentObject.commit ();        }        // }    }
public {get {Object (String key) {/ / settingsTable = persistentObject.getContents () (Hashtable);}}}        Return settingsTable.get (key);    }
public void set (String key, Object value) {if (value == null) {settingsTable.remove (key);}        } else {settingsTable.put (key, value);        }
}
public void commit() {try {synchronized (persistentObject) {persistentObject.setContents (settingsTable);}                persistentObject.commit ();            }
} catch (System.Exception e) {e.printStackTrace ();            System.out.println ("PERSISTENCE of EXCEPTION:" + e.getClass () + "" + e.getMessage ());        }    }
public static DataPersistance getInstance() {if (dataPersistance! = null) {System.out.println ("retornando um DataPersistance ja existente.");}            Return dataPersistance;        } else {System.out.println ("instanciando um DataPersistance.");            dataPersistance = new DataPersistance();            Return dataPersistance;        }    }
}

[/ code]

Why get this error on a COnnection.open? I don't have to commit to anything, don't getContents();

Thank you

I am very confused.  If you don't keep all objects, so how can you have a NonPersistableObjectException?

We see in the code that you create an empty hash table and it is persistent.  Hashtable is persistent.  So this will not cause your problem.  So it seems logical that you have in fact, directly or not, add an object to the list of objects to be persisted.  You can do this without knowing it.  If you add the object to the hash table and object has a reference to object B, then it will also persist object B.  A, otherwise it won't be able to recreate the object A.  Now maybe object A is Persistable (like the hash table) but is not object B.  This causes the problem.

So, as I said before you have to go through all the ' together do you and know what objects you are directly and indirectly adding to PersistentStore.

I have another change of code to suggest that, in my opinion, could well help to find this problem.  in your

Public Sub set (...)

method, add a call to commit.  This will attempt to commit as soon as you add an object.  And you will likely (but not guaranteed to be 100%) to have this failure on the object that you add, and that is not persistent.

I do not understand why you have given us your connection class.  What is there to do with the problem?

Finally, if you hover over the icons in the tool bar layout you see when you create a message, you will see tooltips.  Icons will say "Insert Code".  Press and paste the code into the window that opens.  Do it after you have checked your post, as it used to be that the spellcheck spoiled some of the formatting of the code.

Tags: BlackBerry Developers

Similar Questions

  • How do I solve the NonPersistableObjectException

    I have a method that is simple, written in the form:

    Public Shared Sub set (long uniqueId, String value) {}
    Store = PersistentStore.getPersistentObject (uniqueId);
    synchronized (store) {}
    store.setContents (value);
    Store.Commit ();
    }
    }

    This method works very well for the first time, but the second time, it will fail with NonPersistableObjectException.

    Point to be noted is that same unique identification number, I'm updating with the same value.

    You have created an object that extends the string that you store?  If so, you will need to implement Persistable in this object.

    Your own object is also a good idea.  But there is a problem with persistent objects when you upgrade the.  Say, you create an object as follows:

    class MyPersistentObject extends Persistable {}

    String _string1 = null;

    String _string2 = null;

    ....

    String getString1() {}

    Return _string1;

    }

    ...

    }

    Now for V2, you want to add another string, so you must

    class MyPersistentObject extends Persistable {}

    String _string1 = null;

    String _string2 = null;

    String _string3 = null;

    ....

    String getString3() {}

    Return _string3;

    }

    ...

    }

    Now because you have changed the structure of this persistent object, you actually have the persistent class on the incompatible device with your upgrade.  To install, users will have to delete the old application, lose the stored data.

    However if you did to begin with:

    class myPersistedObject extends IntHashTable implements Persistable {}

    ...

    String getString1() {}

    Return this.get (1);

    }

    ....

    }

    Then to add another channel, you simply add the get method:

    class myPersistedObject extends IntHashTable implements Persistable {}

    ...

    String getString3() {}

    Return this.get (3);

    }

    ....

    }

    The structure does not change and it is compatible.

    The above code is NOT correct, I hope you get the idea.

    Then create your own class, but extends a Collection object and you get the flexibility and scalability.

    Hope it makes sense.

  • NonPersistableObjectException on commit () [code]

    I use the following data record to store relevant data as a persistent object:

    [code]

    Import packages
    Net.rim.device.api.util import. *;
    Import Java.util;

    / public class SentBM_Data implements Persistable
    {
    Private members
     
    Public members
    public int ID;
    public boolean initialized = false;
    public int PIN;
    public Vector storedPackets;         Datagram
    public Vector brokenServer;          Byte]
     
    Builders
    public SentBM_Data)
    {
    for (int count = 0; count)< 50;="">
    {
    Debugging
    System.out.println ("created data object");
    }
        
    storedPackets = new Vector (1, 1);
    brokenServer = new Vector (1, 1);
    }
     
    public SentBM_Data (int boxID)
    {
    Debugging
    System.out.println ("created data object");
        
    storedPackets = new Vector (1);
    brokenServer = new Vector (1, 1);
        
    ID = boxID;
    }
     
    public static generateID Sub)
    {
    TODO: Check in with the BlackBerry PIN
    TODO: set the ID field to the returned boxID (default if PIN invalid)
    }
     
    public String toString)
    {
    String content = "";
        
    content += "case ID:"+ ID + "\n"; '.
    content += "Initialized?:" + initialized + "\n"; "."
    content += "PIN:" + PIN + "/ n"; "."
    content += "Unbuilt stored packages:"+ brokenServer.size () + "\n"; '.
    content += "built the stored packages:"+ storedPackets.size () + "\n"; '.
        
    return the content;
    }
    }

    [/ code]

    I have an appData global object of the type SentBM_Data in which I make the changes and use the following code to commit the changes:

    [code]

    synchronized (BSMData)
    {
    BSMData.setContents (appData);
    BSMData.commit ();
    }

    [/ code]

    For some reason any him commit this change started recently throw a NonPersistableObjectException, even a new run (flash memory at the start of simulator of compensation). I was getting this error before, and I've changed anything which involves the recording of the above data and receive this error message. Any ideas?

    Current Simulator: Bold 9000

    EDIT: I should mention that I use Eclipse version 3.4.1 with plugin 1.0.0.67 version

    Make a differential diagnosis in commenting on the two carriers first and see if you can store the object.

    If it works, comment in the vector with the Byte [] and if it works comment back of the vector with the object of datagram, if it fails, then you know why.

    Looking through the JavaDoc, you will find the following elements of the Persistable interface

    A class must explicitly implement this interface for the system store instances of the persistent class. Make the subfamily (s) not inherit implementation of this interface.

    Class DatagramBase (that implements the datagram that implements Persistable new) does not implement explicitly Persistable not it he inherited only from its super class DataBuffer, which means according to the JavaDoc comment above, that DatagramBase objects are not persitable.

  • ObjectGroup and NonPersistableObjectException

    I'm trying to reduce my handles in memory by using the ObjectGroup.createGroup () on an array of objects.  JDE 4.1 documentation says nothing on objects that need to be Persistable or that a NonPersistableObjectException can be lifted.  The JDE 4.3 mentions in the intro to the class that he is persistent, but doesn't mention the exception.

    Is there a way to group non-persistent objects?

    Thank you

    Philippe

    I think that the only reason why they put in the Persistable obligation is therefore to make the programmer know what items may be copied (in the hope, the user takes care and limit the number of objects peristable, preventing the accidental inclusion of large trees of objects).  Otherwise, it seems to be an unnecessary restriction (I've added a bunch of "Persistable implements" but never persist objects and it seems to work).

    Thank you

    Philippe

  • NonPersistableObjectException - how to get around

    Hi all

    I'm trying to store persistent data in my application, but I'm having some trouble, as shown in the subject. I created a simple data object to contain several values and store it using the BlackBerry API of persistence. When I call commit, he doesn't seem to like the object I created. Is this a problem with the structure of calling code, or only some objects persistables use the API? If this is the case, what are the acceptable storage objects? (I would avoid using something like an array of strings, if possible)

    On a semi-connexe note, are part of the J2ME ArrayList? If so, are they persistable? That would be an acceptable substitute to an array of strings.

    Thank you

    ~ Dom

    Your "simple data record object" does Persistable?

  • Capture of IOException errors

    Hello. I'm a newbie, so don't know if I'm still on the right track. Have a screen that updates storage persistent (v 5.0 SDK). The code that I have seen used a save() so code method he ran was:

    public void save() throws IOException {}
    persistentHashtable.put ("WebURL", editWebURL.getText ());
    persistentObject.commit ();
    }

    What I've done now is overloaded onSavePrompt() and included a save button on my screen instead. So now I want to do is use the button to save the object of persistent storage and display a success message or a message that failed. So I tried with no joy-

    Public Sub saveOptions() throws IOException {}
           
    try {}
    persistentHashtable.put ("WebURL", editWebURL.getText ());
    persistentHashtable.put ("PrimaryPhone", editPrimaryPhone.getText ());
    persistentHashtable.put ("SecondaryPhone", editSecondaryPhone.getText ());
    persistentHashtable.put ("PhoneBySMS", editPhoneBySMS.getText ());
    persistentObject.commit ();
    UiApplication.getUiApplication () .pushModalScreen (new CustomDialog ('saved successfully details.'));
    } catch (IOException e) {}
    UiApplication.getUiApplication () .pushModalScreen (new CustomDialog ("Error" + e.getMessage ()));
    }

    If I have this way then I get an error everything must be taken or declared adjourned. If anyone can tell me what I need to do to make this work? the original save() worked without any testing / catch statement but then how can I catch any type of error and display it? I assume that throw IOException is the best way or y at - it another way to do this? I want to just make sure that the application will not hang or fail because an error is not caught. Any help would be appreciated.

    I've never had or any of these errors in the "production", I don't see how it would be possible to get the NonPersistableObjectException of production that you won't find in tests (assuming that your code coverage is good) and I have simply never seen a content problem.

    But if you want to be 100% sure, I would just do something like

    try {}

    catch (Exception e) {}

    the error in the log and stop the app

    }

    I would think long and hard about how you connect activities and errors reported by your application.  Throw up a dialogue in front of your username is probably not a proper thing to do.  One approach is to keep a record of the actions your app as and when you get an error, propose to send an email to support with the content and an indication of error.  Once you have devices this strategy, what to put in the management of exceptions becomes so much easier.

    Either said by the way, do you really need modal screens here?  And have you looked at Status.show (...) for the success, so that the user doesn't have to make disappear?  Do not expect an answer, just a thought.

  • Problem with PersistentObject.

    Hi all

    I am new to the BB and bad English (I'm Thai), sorry if you confuse in my words. I have a project that has thead to download the server image and record in PersistentObject using my CustomHashTable. The problem is that I have an error message "NonPersistableObjectException", which is based on the method "persistentObject.commit ();" in "getEncodedImage()" when I debug, here is my code.

    public class TestApp extends UiApplication{
    
        public static void main(String[] args) {      UiApplication app = new TestApp();        app.enterEventDispatcher();   }
    
      TestApp(){        pushScreen(new TestScreen()); }}
    
    public class TestScreen extends MainScreen{
    
       EncodedImage encodedImage;    CustomHashTable persistentHashtable;  private DataInputStream dis;  private byte[] encodeData;    private ByteArrayOutputStream byteStream; PersistentObject persistentObject = PersistentStore.getPersistentObject(0x61a0ab9f850b5c9bL);
    
      TestScreen(){     super();      if (persistentObject.getContents() == null) {         persistentHashtable = new CustomHashTable();          persistentObject.setContents(persistentHashtable);            persistentObject.commit();        }else {           persistentHashtable = (CustomHashTable)persistentObject.getContents();        }     encodedImage = getEncodedImage("http://download.magikmobile.mobi/scodp/mpreview.do?idc=683979&size=140x90&","4952","hot");       encodedImage = scaleImage(encodedImage);
    
          this.setTitle("Test my app");     this.add(new BitmapField(encodedImage.getBitmap()));  }
    
      public EncodedImage scaleImage(EncodedImage image) {      int displayWidth = Fixed32.toFP(Display.getWidth());      int imageWidth = Fixed32.toFP(image.getWidth());      int scalingFactor = Fixed32.div(imageWidth, displayWidth);        EncodedImage scaledImage = image.scaleImage32(scalingFactor, scalingFactor);      return scaledImage;   }
    
      public EncodedImage getEncodedImage(String url, String id, String catagory) {
    
           EncodedImage enc = null;      if (persistentHashtable.containsKey("EncodeImage01")) {           enc = (EncodedImage)persistentHashtable.get("EncodeImage01");     }
    
            if (enc != null) {          System.out.println(">>>>>  image not null");            return enc;        } else {            System.out.println(">>>>>  image null");            try {                String newURL = null;                while (url.indexOf("&") > 0) {                    newURL = url.substring(0, url.indexOf("amp;"));                    url = url.substring(url.indexOf("amp;") + 4);                    url = newURL + url;                }
    
                    newURL = null;                String suffix = "";                HttpConnection httpConnection = (HttpConnection) Connector.open(url+suffix);                httpConnection.setRequestMethod(HttpConnection.GET);                if (httpConnection.getResponseCode() == 302) {                   boolean b = true;                    while (b) {                        if (httpConnection.getResponseCode() == 200) {                            b = false;                            break;                        }                        httpConnection = (HttpConnection) Connector.open(httpConnection.getHeaderField("Location"));                    }                }                dis = httpConnection.openDataInputStream();                int length = (int) httpConnection.getLength();                if (length > 0) {                    encodeData = new byte[length];                    dis.readFully(encodeData);                } else {                    byteStream = new ByteArrayOutputStream();                    int ch;                    while ((ch = dis.read()) != -1) {                        byteStream.write(ch);                    }                    encodeData = byteStream.toByteArray();                    byteStream.close();                    byteStream = null;                }                dis.close();                dis = null;                httpConnection.close();                httpConnection = null;                try {                    enc = EncodedImage.createEncodedImage(encodeData, 0, encodeData.length);                } catch (OutOfMemoryError e) {                  System.out.println(">>>>  OutOfMemoryError");                    e.printStackTrace();                    return null;                } catch (NullPointerException e) {                 System.out.println(">>>>  NullPointerException");                    e.printStackTrace();                    return null;                } catch (IllegalArgumentException e) {                 System.out.println(">>>>>  IllegalArgumentException");                    e.printStackTrace();                    return null;                } catch (ArithmeticException e) {                  System.out.println(">>>>  ArithmeticException");                    e.printStackTrace();                    return null;                }                encodeData = null;                persistentHashtable.put("EncodeImage01", enc);                persistentObject.commit();                catagory = null;                id = null;                url = null;                return enc;            } catch (SecurityException ex) {                ex.printStackTrace();                return null;            } catch (IOException ex) {                ex.printStackTrace();                return null;            }        }    }
    
    }
    
    public class CustomHashTable extends Hashtable implements Persistable{
    
    }
    

    What should I do?

    Thank you very much

    ~ MazMellow ~.

    I see no problem here, hashtable will have any object as second parameter to the function, so you can put hashtable in storage of place (it is supported and commonly used):

    Hash hash = new Hashtable();

    data Byte [] = image.getData ();

    Hash.put ("first", data);

    ....

    ...

    ...

    ....

    data Byte [] (byte []) = hash.get ("first");

    image = EncodedImage.createEncodedImage (data,...);

  • Bold persistent store sometimes be served.

    Hello

    The game I'm working on guard various objects in a store persistent user prefs, game, etc. recorded title screen  On the Pearl, curve and 8800 it works, fine, but on the BlackBerry 9000 "BOLD" it seems that the persistent store sometimes becomes commit() or forceCommit() at an unexpected time in the runtime.  This happens while the device is left idle and turn off the backlight.

    It seems like a reasonable thing to do for this opportunity to make sure everything is saved, however, at times the items in the store are not suitable for the economy, and this throws a NonPersistableObjectException.

    Is there anything (events on demand / triggered by the operating system) that could be the cause?  I'm reworking the game to remove all of the Bank when it is used.  Is that reasonable?  Any advice would be appreciated.

    Thank you

    Steven.

    A validation can be called when the garbage collection operation is underway.  You can read about the different types of garbage collection in this white paper.

    Collection in the BlackBerry Java development environment

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe?func=LL&objid=832210&objAction=browse&s...

  • Poblem to persistence storage

    Hi all

    In my application, I use the persistence store object to store the array of objects of the class defined by the user. But whenever I run my application it showed me the error 'Error JVM 104 NonPersistableObjectException' 7 stucks execution.

    In the integer part of the persistence object & all what I have try-catch instructions & I also tried with execution clean.bat hundreds of times. But I didn't come to any solution.

    Is there be no problem by storing the array of objects of class user-defined?... Please help me...

    Any help would be appreciated...

    Concerning

    Please note that all the objects that you want to store in the persistent store must be an instance of the class that implements the Persistable.

    In addition, all areas inside these objects must be an instance of the class that implements the Persistable.

    If the container object implements the Peristable interface, but there is a field that is not persistent, you get problems.

    Another point is that if you have an instance of Vector field, check this vector elements.

    All objects in this vector (or another container as an instance of the Hashtable object) must be an instance of the class that implements the Persistable.

Maybe you are looking for

  • I lost the icon 'remove hardware safely '.

    Hi all I lost the icon 'Remove hardware safely' in the notification bar, I can see on the left side of sreen in respect of the points made, can someone tell me how to get it back? I use os XP with SP 3 with 1.3 proccesser. I think that the problem ar

  • The computer will not start blank screen

    I can't computer Dell 4600 my wife to start.  White screen. I have a Trojan horse, or the boot order has changed. I can't run antivirus software in safe mode. Maybe bad hard drive? d_may

  • Main hard drive has lost recently. (2 mo out of warranty)

    Lost the main hard drive on p6717c running Win 7 Home premium 32-bit.  Warrentey expired on 19/02/12.  Hard disk was sent to see if they can recover more than 50,000 family photos.  they don't know if they can recover the op system.  If recovery is p

  • BSOD DRIVER_IRQL_NOT_LESS_OR_EQUAL (ndis.sys)

    Hello Microsoft community. Yesterday I installed Oracle VM and used for a short stint with no problem or what so ever, and all of a sudden today when my computer starts, I had this BSOD I have L17 no idea on what to do to solve this problem! Help: x

  • Windows could not start service Security Center, Windows 7

    I am using windows 7 ultimate in my laptop, but whenever I try to open the security service windows to open action center located on the menu to the Quick Launch bar, it generates an error message stating: "Could not start the windows Security Center