Cannot be cast to javassist.util.proxy.Proxy error

Hi @ibacher , @gcliff , @dkayiwa ,

I’ve added fhir2 module in my core module and openmrs started successfully after that. However, while fetching data from the database through Criteria, it is throwing an exception.

Criteria criteria = sessionFactory.getCurrentSession().createCriteria(xyz.class);
                criteria.add(Restrictions.eq("requester", provider));
		List<xyz> list = (List<xyz>) criteria.list();
		return list;

The function criteria.list() is throwing this error - org.module.core.xyzt_$$_jvst774_69 cannot be cast to javassist.util.proxy.Proxy

This error is coming only when I’m adding fhir2 module.

This usually happens when you have two versions of Javassist on the classpath. Is the module publicly available on GitHub for us to take a look?

May actually be the FHIR2 module… Looks like we’ve accidentally been bundling the version of Javassist from OMRS 2.0.5 due to some issues with deep dependency trees. I’m working on fixing that for the 1.2.2 release.

Hi @ibacher ,

Do you have any idea by when it’ll be fixed as this a major part of the project we’re working on ?

Well, version 1.2.2 of the FHIR2 module no longer bundles a version of Javassist so if that was the cause of your issue, you should be able to download and use that version (released yesterday).

Hi @dkayiwa, @ibacher ,

I’ve added fhir2 1.2.2 module in my core module but after performing an operation, it is throwing this error - java.lang.NoClassDefFoundError: com&#47;google&#47;gson&#47;JsonElement org.hl -

I’m performing this operation - org.hl7.fhir.r4.model.Bundle bundle = (Bundle) parser.parse(“Validated Resource JSON”);

@chughrahul Could you provide, e.g., the source code for the module you’re working on? There isn’t much to go on here.

Hi @ibacher ,

Here is the snippet of the source code for the module.

The line bundle = (Bundle) parser.parse(healthInfo); is throwing this error. Also the json healthInfo is validated using fhir r4 validator.

Use HAPI’s FhirContext to get a JSON parser rather than SimpleContextWorker. You can even get one from the Spring context, e.g.,

private FhirContext fhirContext;


fhirContext.newJsonParser().parseResource(Bundle.class, healthInfo);

Or you can bundle the appropriate version of GSON in your own module.

@ibacher Is there any other method other than importing the ca.uhn.fhir.context.FhirContext because I tried it but it throws error due to clash between ca.uhn.fhir & org.hl7.fhir

(Need FHIR2 encounter create and update calls - #15 by ibacher)

I used SimpleContextWorker in the place of FhirContext due to these reasons.

The other method is:

What error does it throw? What clash is there? Do you have a concrete example of something that fails?

Thank you for your support.

It is resolved by using the ca.uhn.fhir and no error is coming now :slight_smile: