Context: I am working on migrating the Patient Flags Module to support Java 21 and OpenMRS 2.8.0. While the API logic is updated, I am stuck on a persistent NoSuchTableException during unit tests in the :patientflags-api module.
The Problem: When running FlagTest, all 12 tests fail with a DatabaseUnitRuntimeException caused by org.dbunit.dataset.NoSuchTableException: patientflags_flag. It appears the table is not being created in the H2 in-memory database before DBUnit attempts to load the XML dataset.
Technical Details:
- Environment: Java 21, OpenMRS 2.8.0.
- Test Class: Extends
BaseModuleContextSensitiveTest. - Hibernate Mappings: Confirmed
Flag.hbm.xmland others are insrc/main/resources. - Test Configuration:
test-hibernate.cfg.xmlincludeshibernate.bytecode.provider=bytebuddyandhibernate.hbm2ddl.auto=update.TestingApplicationContext.xmlis configured to merge module mappings, though I have experimented with both overriding thesessionFactoryand letting the core merge them.
What I have tried:
- Dataset Integrity: Fixed the XML dataset sequencing (ensuring
PersonprecedesPatientandMetadataprecedesConcepts). - Java 21 Proxying: Added the ByteBuddy agent to the Maven Surefire configuration to handle proxying errors.
- DAO Layer: Updated
HibernateFlagDAOto ensure it correctly interacts with theDbSessionFactory.
Error Snippet:
Plaintext[ERROR] FlagTest.initTestData:43->BaseContextSensitiveTest.executeDataSet:723 Caused by: org.dbunit.dataset.NoSuchTableException: patientflags_flag
PR Link for Reference: FLAG-87: Complete Configuration to Platform 2.8/Java 21 (Resolves All Compiler Issues) by Abhxay · Pull Request #104 · openmrs/openmrs-module-patientflags · GitHub
I would appreciate any guidance on why Hibernate 5 might be failing to generate the schema from module .hbm.xml files in this specific environment.