Error: Unable to deserialize Report

Hi I have been looking into the Reporting Module and I noticed that occasionally all reports would disappear.

attachments

This usually happens after restarting an OpenMrs instance and seems to be more frequently when there is a change in an existing report.

Running:

  • OpenMrs 2.4.0
  • Reporting Module 1.21.0
  • Serialization Xstream 0.2.14

The error logs can be seen bellow:

A similar issue was reported in the talk:

After looking into the database (serialized_object table), the report seems to contain org.openmrs.User$HibernateProxy$ODcBnusu somewhere inside the column “serialized_data”

A snippet of this can be seen bellow:

...
  <name>HSU monthly days of admission</name>
  <description>HSU monthly days of admission</description>
  <creator class="org.openmrs.User$HibernateProxy$ODcBnusu" id="2" uuid="A4F30A1B-5EB9-11DF-A648-37A07F9C90FB"/>
  <dateCreated id="3">2021-04-15 07:56:57 UTC</dateCreated>
  <changedBy id="4" uuid="1c3db49d-440a-11e6-a65c-00e04c680037"/>
....

Do you have any clue @dkayiwa, @mksd, @mseaton

Thanks @icrc.thonorio for sharing your findings.

The reports that disappear seem to share a common trait: their serialized report definitions’ <creator/> contains an Hibernate proxy class name. This is very similar to what what was happening back in 2015 and described on that other thread.

  • Back then it was because of Javaassist names, eg. "org.openmrs.User_$$_jvst6de_41".
  • Now it’s because of Hibernate proxy names, eg. "org.openmrs.User$HibernateProxy$ODcBnusu".

@icrc.thonorio looks like we need to expand on @mogoodrich’s fix of back in the days, see SXS-24 here ; or that we figure out what process writes those names and then do something like what was done here by @icrc.psousa on Data Filter: Rely on Hibernate getClass method on entities to avoid getting proxy … · openmrs/openmrs-module-datafilter@027d476 · GitHub

The latter may be difficult as this may be happening in XStream itself. XStream was upgraded often recently actually, you can git blame this line to see that: openmrs-core/pom.xml at e9703b6094a0ffc244b66ce62319af7b2550eb09 · openmrs/openmrs-core · GitHub

I completely agree!

We could enhance CGLibMapper by adding here: openmrs-module-serialization.xstream/CGLibMapper.java at 0.2.14 · openmrs/openmrs-module-serialization.xstream · GitHub

Something along these lines.

Fixed with: https://issues.openmrs.org/browse/SXS-30