Error in dynamic class casting after the build

98 Views Asked by At

In my application, we are doing dynamic class casting where lot of implementations are there (Please refer pic). The application is working fine when it is running in eclipse but not after the build (mvn clean install).

enter image description here

Loading data from XML,

ClinicalDocument cda = // loads data from XML

While running the application in eclipse, the following casting is working fine.

ContinuityOfCareDocument ccd = (ContinuityOfCareDocument) cda;

But after the build (mvn clean install), ClassCastException occurs.

org.openhealthtools.mdht.uml.cda.impl.ClinicalDocumentImpl cannot be cast to org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument

If anyone know how to resolve it, your help would be immense.

1

There are 1 best solutions below

0
On

MDHT has libraries (jars) that need to be loaded before the fist load It uses the template id to create the correct corresponding java class This error happens when the consol library has not been loaded

There is a CDAUtil.loadLibraries() which will initialize all cda based libraries in the class path so if that is included in the pom should be fine

you can also initialize by ConsoPackage.eInstance().getContinuityOfCareDocument();