Fix Infinispan/Java 21+ startup failure by disabling Hibernate L2 cache#113
Merged
dkayiwa merged 1 commit intoopenmrs-emr3from Feb 28, 2026
Merged
Fix Infinispan/Java 21+ startup failure by disabling Hibernate L2 cache#113dkayiwa merged 1 commit intoopenmrs-emr3from
dkayiwa merged 1 commit intoopenmrs-emr3from
Conversation
Member
Author
|
@copilot remove .DS_Store |
Contributor
cfa113d to
c1ab906
Compare
Disable Hibernate L2 cache in openmrs-runtime.properties by setting hibernate.cache.use_second_level_cache=false. This prevents Infinispan from initializing, avoiding the Java 21+ incompatibility where Subject.getSubject() throws UnsupportedOperationException (removed entirely in Java 24 via JEP 486). OpenMRS's HibernateSessionFactoryBean merges runtime properties into the Hibernate config, so this single property prevents Infinispan's InfinispanRegionFactory from ever being created. For a standalone/demo distribution the L2 cache performance impact is negligible. See PR #112 for an alternative approach that keeps L2 caching by patching the Infinispan WAR. Also sync the Bootstrap.java default vm_arguments with the runtime properties by adding the missing --add-opens flag. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c1ab906 to
62e65a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Infinispan 13.0.22 (bundled in OpenMRS Core 2.8.4) calls
Subject.getSubject()during initialization, which throwsUnsupportedOperationExceptionon Java 21.0.4+ and is removed entirely in Java 24 (JEP 486).Fix
Disable Hibernate L2 cache via
hibernate.cache.use_second_level_cache=falsein the runtime properties. OpenMRS'sHibernateSessionFactoryBeanmerges runtime properties into Hibernate config, so this prevents Infinispan from ever initializing.This is the simpler alternative to #112 (which patches the Infinispan WAR to keep L2 caching). For a standalone/demo distribution the performance impact is negligible.
Changes
src/main/config/openmrs-runtime.properties: Addhibernate.cache.use_second_level_cache=falsesrc/main/java/org/openmrs/standalone/Bootstrap.java: Sync default vm_arguments to include--add-opens=java.base/java.lang=ALL-UNNAMEDCompatibility
Works on Java 21, 24, 25, and all future versions (no dependency on Security Manager APIs).