Gentry Member Licensed User Longtime User Feb 14, 2018 #1 I am encountering a sporadic error from within a class module when trying to save a lists state to file. I started seeing it with WriteB4XObject, and it seemed to stop when i reverted to plain WriteObject, but no it has started again. I am checking the list object (EventList) before attempting to write, but get the object not initialized error anyways. Code: If Main.EventList.IsInitialized Then Main.EventFile.WriteObject(Main.EventList,True,0) Main.EventFile.flush CallSubDelayed(Main,"Load_EventListView") Else CallSubDelayed(Main,"Load_Events") End If and the Error stack: Code: uevent_new_id (java line: 453) java.lang.RuntimeException: Object should first be initialized (List). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:465) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeMap(RandomAccessFile.java:596) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeType(RandomAccessFile.java:545) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:486) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeMap(RandomAccessFile.java:596) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeType(RandomAccessFile.java:545) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:486) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeMap(RandomAccessFile.java:596) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeType(RandomAccessFile.java:545) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:486) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeList(RandomAccessFile.java:647) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:475) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeHelper(RandomAccessFile.java:359) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.WriteObject(RandomAccessFile.java:337) at info.uberpro.helper.uevent._new_id(uevent.java:453) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1038) at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:993) at info.uberpro.helper.fbdb._jobdone(fbdb.java:263) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186) at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1135) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6316) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) EDIT: Additional info, seems to only raise the error when the application is starting up, and it only seems to raise the error from within the class module. In testing I added this same code behind a button and that does not cause the error to occur, even when the app first starts up. It seems that if enough time passses after the app starts, or possibly due to other actions (that don't effect the list ) occur, the error is not raised. any ideas? Thanks for looking. Gentry Last edited: Feb 15, 2018
I am encountering a sporadic error from within a class module when trying to save a lists state to file. I started seeing it with WriteB4XObject, and it seemed to stop when i reverted to plain WriteObject, but no it has started again. I am checking the list object (EventList) before attempting to write, but get the object not initialized error anyways. Code: If Main.EventList.IsInitialized Then Main.EventFile.WriteObject(Main.EventList,True,0) Main.EventFile.flush CallSubDelayed(Main,"Load_EventListView") Else CallSubDelayed(Main,"Load_Events") End If and the Error stack: Code: uevent_new_id (java line: 453) java.lang.RuntimeException: Object should first be initialized (List). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:465) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeMap(RandomAccessFile.java:596) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeType(RandomAccessFile.java:545) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:486) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeMap(RandomAccessFile.java:596) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeType(RandomAccessFile.java:545) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:486) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeMap(RandomAccessFile.java:596) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeType(RandomAccessFile.java:545) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:486) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeList(RandomAccessFile.java:647) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeObject(RandomAccessFile.java:475) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.writeHelper(RandomAccessFile.java:359) at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.WriteObject(RandomAccessFile.java:337) at info.uberpro.helper.uevent._new_id(uevent.java:453) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1038) at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:993) at info.uberpro.helper.fbdb._jobdone(fbdb.java:263) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186) at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1135) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6316) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) EDIT: Additional info, seems to only raise the error when the application is starting up, and it only seems to raise the error from within the class module. In testing I added this same code behind a button and that does not cause the error to occur, even when the app first starts up. It seems that if enough time passses after the app starts, or possibly due to other actions (that don't effect the list ) occur, the error is not raised. any ideas? Thanks for looking. Gentry
Erel B4X founder Staff member Licensed User Longtime User Feb 15, 2018 #2 You should use WriteB4XObject. Based on the error message you are trying to write a type that has a map field where one of the values is not initialized. Upvote 0
You should use WriteB4XObject. Based on the error message you are trying to write a type that has a map field where one of the values is not initialized.