However it seems that this should precisely be addressed by Xstream through the resolves-to="org.openmrs.User" attribute, and it does not. Am I wrong?
Also as you can see I had to omit some fields here and there (thankfully irrelevant for what I was doing) but I have no idea why I had to that. If I were not to omit them, Xstream would complain that the fields could not be found.
I have the feeling, looking at the output XML, that ReportingSerializer probably does the right thing.
The problem is: I need to unmarshall it within JUnit… and I am then getting this:
com.thoughtworks.xstream.converters.ConversionException: Service not found: interface org.openmrs.module.reporting.report.definition.service.ReportDefinitionService
@mksd, not sure exactly what you are trying to do, but if you can share your junit test we can have a look. Presumably you have the reporting module as a dependency already if you are working with ReportData instances. You’ll need to make sure you are using a context sensitive test, and likely also need to ensure you have the reporting module hibernate mapping files referenced from your test resources like this:
However, although I can see that it produces a slightly different output XML, it still leaves Hibernate proxies class names in those <creator/> and <changedBy/> tags in the XML:
Probably.
So those funny named classes are not Hibernate proxies but Javaassist related objects…
Anyway then I tried this both for marshalling and unmarshalling:
I could see that the <creator/> and <changedBy/> tags were still holding those funny org.openmrs.User_$$_jvst.. package names after marshalling (so I had not much hope regarding the way back anyway).
Just to be sure, is this how I am supposed to use the custom Converter?
I am also on OpenMRS 1.10.+ so I guess it all makes sense… that it doesn’t work
@mksd can we look at your unit test where you marshal with ReportingSerializer and get Service not found: interface org.openmrs.module.reporting.report.definition.service.ReportDefinitionService?
On the contrary, that’s the workaround that makes it work by telling Xstream to reconstruct org.openmrs.User_$$jvst70541 as a org.openmrs.User. It would fail without setting this alias.
As I said earlier, it is the equivalent of Mark’s trick explained in the other thread.
The question is rather: how do we get Xstream to not generate those org.openmrs.User_$$jvst* markups when marshalling in the first place?
I provided you with an XML that was marshalled with Xstream directly, I believe you may need one that would be marshalled using ReportingSerializer then? Please confirm.
Please also have a look above at my last answer to @mseaton regarding my trials in that direction.