ObjectDB ObjectDB

Failed to read the value of field using reflection

#1

I have recently encountered an issue with reading objects:

Exception: com.objectdb.o.UserException
Message: Failed to read the value of field field Character.stats using reflection

Stack Trace:
com.objectdb.o.MSG.d(MSG.java:75)
com.objectdb.o.UMR.P(UMR.java:934)
com.objectdb.o.UMR.B(UMR.java:609)
com.objectdb.o.UML.v(UML.java:549)
com.objectdb.o.MMM.ah(MMM.java:1103)
com.objectdb.o.UTY.aG(UTY.java:1331)
com.objectdb.o.UTY.aF(UTY.java:1303)
com.objectdb.o.ENH.b(ENH.java:102)
com.objectdb.o.LDR.J(LDR.java:800)
com.objectdb.o.LDR.U1(LDR.java:1031)
com.objectdb.o.MST.aX(MST.java:544)
com.objectdb.o.MST.aY(MST.java:605)
com.objectdb.o.MST.U9(MST.java:565)
com.objectdb.o.WRA.U9(WRA.java:279)
com.objectdb.o.LDR.F(LDR.java:563)
com.objectdb.o.LDR.E(LDR.java:470)
com.objectdb.o.OBC.UO(OBC.java:1080)
com.objectdb.o.ENT.d(ENT.java:1144)
com.objectdb.o.ENT.extractCollection(ENT.java:1505)
objectdb.java.util.ArrayList.__odbBeforeAccess(Unknown Source)
objectdb.java.util.ArrayList.size(Unknown Source)
Player.toSFSObject(Player.java:45) <-- this is my code from here. I am trying to access the size of a List of an object I fetched from the database.
...

The database was working before, then I decided to implement concurrency and replaced all maps from HashMap to ConcurrentHashMap (and added a converter callback attached to @PostLoad event so I get my concurrent hashmaps back after load). However, I noticed that even if I replace the ConcurrentHashMap in question, Characer.stats, with HashMap again, the error persists.

What exactly happened is that I first created and persisted a player, who can have various characters (also an entity). That worked fine. I can manipulate the object fine. Then I saved, quitted and reloaded the database. Then I try to count the number of characters my player object I fetched from the database. This generates the above error. It seems like it is trying to fetch all the characters from the database first, and failed to do so.

I am using ArrayList to store characters on player, and Map<Stat, Integer> (where Stat is an Enum) to store stats on character. I am using the latest ObjectDB (2.6.3), the database looks fine in explorer and database doctor returned no errors.

What could have went wrong here?

edit
delete
#2

There should be another stack trace with the cause of this stack trace. Please check the log file.

ObjectDB Support
edit
delete
#3

It appears that this is caused by using ConcurrentHashMap instead of Map type, so when ObjectDB attempts to load and cast the loaded HashMap (as they are stored) into former, it throws that error.

It also appears that after I fixed it by using Map and casting it to ConcurrentHashMap after @PostLoad, Eclipse threw a project error so I was seeing old code. There is no longer a problem! :)

edit
delete

Reply

To post on this website please sign in.