Failed to read the value of field using reflection


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.ENT.extractCollection( Source) Source)
Player.toSFSObject( <-- 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?


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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

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! :)

Post Reply

To post a reply and/or subscribe to update notifications - please login