Skip to content

build(deps): replace unused Ehcache 3 with the Ehcache 2.x in use - #729

Open
Naenyn wants to merge 1 commit into
uPortal-Project:masterfrom
Naenyn:build/ehcache-2-declare-directly
Open

Naenyn wants to merge 1 commit into
uPortal-Project:masterfrom
Naenyn:build/ehcache-2-declare-directly

Conversation

@Naenyn

@Naenyn Naenyn commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Why

The build declares Ehcache 3 (org.ehcache:ehcache), but the portlet uses Ehcache 2.x (net.sf.ehcache) everywhere:

  • CacheConfiguration uses Spring's EhCacheManagerFactoryBean / EhCacheCacheManager, which are 2.x-only.
  • CacheNotificationService, ClassLoaderResourceNotificationService, PortletEventNotificationService and AbstractJdbcNotificationService import net.sf.ehcache.Cache / Element.
  • ehcache.xml is in the 2.x format (bare <ehcache> root, <cache name=...>).
  • Nothing in src/ references org.ehcache, javax.cache or JCache.

How it got this way

  • Until 2020 the build declared net.sf.ehcache:ehcache:2.10.6.
  • 3bdf7bb (June 2020, "chore: upgrade ehcache to new package and version 3.8.1") changed only the coordinates: net.sf.ehcache:ehcache → org.ehcache:ehcache:3.8.1. Ehcache 3 is not a package rename, though. It's a different API and XML schema, and the code, config and Spring wiring were never migrated.
  • Nothing broke because hibernate-ehcache 5.6.15 depends on net.sf.ehcache:ehcache at compile scope. So the 2.x classes kept arriving transitively, and the Spring Boot 1.x dependency-management BOM resolved them to 2.10.5.
  • Renovate has kept bumping the unused 3.x artifact since (3.9.0 → 3.10.8 → 3.12.0 in fix(deps): update dependency org.ehcache:ehcache to v3.12.0 #676). Ehcache 3.12.0 is compiled for Java 17 (class version 61). It ships in the WAR on our Java 11 runtime and is only harmless because nothing loads it.
  • The exclude group: 'net.sf.ehcache', module: 'ehcache-core' on hibernate-ehcache matches nothing. Hibernate 5.6 depends on ehcache, not the old ehcache-core artifact name.

Change

  • Declare net.sf.ehcache:ehcache directly at 2.10.5, the version resolved today. The code imports it, so it shouldn't rely on a transitive path through Hibernate.
  • Remove org.ehcache:ehcache (3.12.0).
  • Remove the no-op ehcache-core exclusion.
  • Comment on ehcacheVersion explaining that it's 2.x on purpose.

No runtime version change: the Ehcache 2 jar in the WAR is 2.10.5 before and after.

Verification

Built from current master (before) and this branch (after) on Java 11 with the Gradle wrapper (6.9.4):

  • ./gradlew check -S --no-daemon --no-parallel (same as CI) → BUILD SUCCESSFUL. All 4 tests pass.
  • dependencyInsight --dependency ehcache on runtimeClasspath: net.sf.ehcache:ehcache:2.10.5 before and after. org.ehcache:ehcache is gone.
  • WEB-INF/lib diff, before → after: only ehcache-3.12.0.jar and cache-api-1.0.0.jar (the JSR-107 API, pulled only by Ehcache 3) are removed. Nothing else changes.
  • Not verified: runtime behavior in a deployed portal. The test suite is small (4 tests) and doesn't exercise caching. Since the loaded Ehcache classes are unchanged, I expect no difference, but it's worth a quick smoke test of the notifications view.

Follow-ups (not in this PR)

  • A second Ehcache 2 copy is also on the classpath. resource-server-utils 1.5.3 brings net.sf.ehcache:ehcache-core:2.6.11 (via ehcache-web 2.0.4), so the WAR has both ehcache-2.10.5.jar and ehcache-core-2.6.11.jar, with overlapping net.sf.ehcache.* classes. Which copy Tomcat loads isn't guaranteed. That was probably what the no-op exclusion originally meant to prevent. Excluding ehcache-core from resource-server-utils is the likely fix, but it can change which classes load, so it should be tested on a running portal rather than folded in here.
  • chore(renovate): pin ehcache < 3.12.0 (Java 17 floor) #705 (Renovate cap org.ehcache:ehcache < 3.12.0) targets the artifact this PR removes. It can be closed or retargeted once this merges.
  • Moving to Ehcache 3 for real would mean rewriting ehcache.xml and switching Spring to JCache (JSR-107), since Spring 4.3 has no native Ehcache 3 support. That's a migration, not a cleanup.

The code, ehcache.xml and Spring config all use Ehcache 2.x (net.sf.ehcache).
In 2020 the build dependency was switched to org.ehcache:ehcache (3.x)
without migrating the code, so 2.x kept arriving transitively via
hibernate-ehcache and the 3.x jar shipped unused. Renovate has since
bumped it to 3.12.0, which is compiled for Java 17.

Declare net.sf.ehcache:ehcache directly at 2.10.5, the version resolved
today, and drop the 3.x dependency. Remove the ehcache-core exclusion on
hibernate-ehcache, which matched nothing.
@Naenyn
Naenyn requested a review from bjagg November 14, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant