The Bahmni team is currently working on migrating OpenMRS core, migration from the current 2.5.14 to v2.6.15. As part of this ongoing migration, we are facing issues with one of our custom modules - openmrs-module-ipd, a module that was working as expected on OMRS 2.5.15 but not on OMRS 2.6.14. Below is the exact error that we encountered -
openmrs-1 | WARN - AbstractApplicationContext.refresh(591) |2025-09-30T12:29:05,284| Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'procedureOrderExport' defined in URL [jar:file:/openmrs/data/.openmrs-lib-cache/fhir2Extension/lib/fhir2Extension-api-1.4.0-SNAPSHOT.jar!/org/openmrs/module/fhirExtension/export/impl/ProcedureOrderExport.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderServiceTarget' defined in class path resource [applicationContext-service.xml]: Cannot resolve reference to bean 'orderDAO' while setting bean property 'orderDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderDAO' defined in class path resource [applicationContext-service.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-service.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.openmrs.module.ipd.api.model.Slot.medicationAdministration references an unknown entity: org.openmrs.module.ipd.api.model.MedicationAdministration.
The openmrs-module-ipd module was introduced to support In-Patient Department (IPD) functionality. Within this module, the Slot class (api/src/main/java/org/openmrs/module/ipd/api/model/Slot.java) represents a scheduled time window for administering medication to an inpatient. Each Slot maintains a reference to a MedicationAdministration recordâwhenever a medication is administered during a slot, a corresponding MedicationAdministration entry is created and linked to it.
Our initial hypothesis was that in openmrs-module-ipd, the Slot model does not explicitly import MedicationAdministration. Since both classesâSlot (in IPD) and MedicationAdministrationâshare the same package name, Hibernate may have previously resolved the mapping implicitly. However, in newer versions, Hibernateâs entity resolution appears to be stricter, and it can no longer infer this relationship automatically.
Attempts So Far
-
We updated the package name and fixed the imports accordingly (changes here), but the issue persisted.
-
We then added explicit Hibernate mappings using
.hbmfiles, but this also did not resolve the problem. -
The only way weâve been able to get the module to start successfully is by removing the
@OneToOnemapping betweenMedicationAdministrationandSlot. While this allows the module (except SNOMED) to load, it breaks the intended medication administration linkage and functionality.
At this point, weâve exhausted most of the solutions we could think of. We suspect thereâs a subtle issue weâre overlookingâpossibly related to how entities are being scanned or loaded between modulesâbut havenât been able to pinpoint it yet.
We would greatly appreciate any insights, suggestions, or guidance from the community to help us resolve this. If anyone has encountered similar Hibernate entity resolution issues across modulesâor has suggestions on alternate mapping strategiesâplease do share your thoughts.
cc: @ibacher, @dkayiwa, @grace, @raff, @burke, @binduak, @kavitha11, @r.kalai, @angshuonline, @mohant