Skip to content

Conversation

@pdurbin
Copy link
Member

@pdurbin pdurbin commented May 12, 2025

What this PR does / why we need it:

Both @JR-1991 and @ofahimIQSS have had trouble getting the containerized environment working because they had a version of Java that was too new. (For Jan it was Java 23, see discussion.) They're using our dev quickstart: mvn -Pct clean package docker:run

Special notes for your reviewer:
None. Merely adding the missing compile plugin config bits according to the auto-services docs.

Suggestions on how to test this:

  1. Use SDKMAN to have multiple JDK versions at the ready.
  2. Install JDK 17, 21, and 23
  3. With all these versions run mvn clean compile. Confirm all the necessary (3) files are present at target/classes/META-INF/services
  4. If you have Docker on your machine, you can use mvn -Pct clean package docker:run and JDK 23 to verify it works now.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Nope

Is there a release notes update needed for this change?:
Nope

Additional documentation:
None

We've been using the maven-enforcer-plugin plugin and its requireJavaVersion rule since d6c3f7a but it's set for "Java 17 or newer".

In this pull request, I'm suggesting we set it to "Java 17 and not newer". See also "Version Range Specification" at https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html

I'm also simplifying the syntax because I don't think we need .0 in there.

Here's how the output looks (as of this pull request) when you try to use a version of Java that's too new:

[ERROR] Detected JDK version 21.0.4 (JAVA_HOME=/Users/PDurbin/.sdkman/candidates/java/21.0.4-tem) is not in the allowed range [17,18].

@coveralls
Copy link

coveralls commented May 12, 2025

Coverage Status

coverage: 23.141% (+0.07%) from 23.071%
when pulling c27c57b on enforce-java-17
into ac30566 on develop.

@github-actions

This comment has been minimized.

@pdurbin pdurbin moved this to Ready for Review ⏩ in IQSS Dataverse Project May 13, 2025
@stevenwinship stevenwinship moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project May 19, 2025
@stevenwinship stevenwinship self-assigned this May 19, 2025
@github-project-automation github-project-automation bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project May 19, 2025
@stevenwinship stevenwinship removed their assignment May 19, 2025
@ofahimIQSS ofahimIQSS moved this from Ready for QA ⏩ to QA ✅ in IQSS Dataverse Project May 19, 2025
@ofahimIQSS ofahimIQSS self-assigned this May 19, 2025
@scolapasta scolapasta moved this from QA ✅ to In Review 🔎 in IQSS Dataverse Project May 20, 2025
@pdurbin pdurbin moved this from In Review 🔎 to On Hold ⌛ in IQSS Dataverse Project May 28, 2025
@poikilotherm
Copy link
Contributor

poikilotherm commented Jun 4, 2025

Trying to reproduce here. (Without any enforcing rules, using a clean build with our current base images)

  1. When using Java 21 (Temurin LTS), I cannot reproduce the issue. Works!
  2. When using Java 23 (Temurin 23.0.2), I get the "No default PID provider configured" message and the failing config check makes the deployment fail.

The problem was us having missed to add the auto-services annotation processor to the Maven compile plugin. See auto-services docs. Because of this mistake, the META-INF/services files were not generated, disabling the ServiceLoader to pick up the classes at runtime. Simple fix, ensuring future compatibility! Would also have affected the Exporter plugins as same logic applies.

…tation processor #11487

Before JDK 23, the annotation processor for Auto Service was picked up automatically. With newer JDKs, the META-INF/services files were not generated, which made it impossible for the PID Factories to be picked up by the ServiceLoader at runtime.

Following the documentation, we seem to have missed adding the annotation processor to the Maven Build Plugin. Adding this missing bit re-enables the auto-generation on newer JDKs.

See also: https://github.com/google/auto/blob/bb4d48e4ca0bda0e75b3b67f6ff4f464db9304e4/service/README.md
@poikilotherm poikilotherm marked this pull request as ready for review June 4, 2025 11:55
@poikilotherm poikilotherm added Type: Bug a defect Component: Code Infrastructure formerly "Feature: Code Infrastructure" Feature: Developer Guide Size: 0.5 A percentage of a sprint. 0.35 hours labels Jun 4, 2025
@poikilotherm
Copy link
Contributor

poikilotherm commented Jun 4, 2025

@pdurbin this is ready for review and a very simple fix. IMHO this can be fast tracked, as it doesn't affect any code - just making sure the annotation processor works as intended. I tested this with JDK 17, 21 and 23, using mvn -Pct clean package docker:run and looking at target/classes/META-INF/services folder to contain the necessary files and no PID provider not found messages from the log output.

@poikilotherm poikilotherm changed the title enforce Java 17 (no higher) Fix @AutoService classes not being loaded at runtime when using JDK23+ for compilation Jun 4, 2025
@poikilotherm
Copy link
Contributor

poikilotherm commented Jun 4, 2025

The failing image builds are probably Docker Hub hickups. "error pulling image configuration: image config verification failed for digest" is not even remotely related to the changes of the build configuration (compile phase, not package phase).

@github-actions

This comment has been minimized.

@landreev landreev moved this from On Hold ⌛ to In Review 🔎 in IQSS Dataverse Project Jun 4, 2025
@github-project-automation github-project-automation bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Jun 4, 2025
@pdurbin
Copy link
Member Author

pdurbin commented Jun 4, 2025

I tested with Java 21.0.4-tem and it worked fine. Thanks, @poikilotherm . This is really your PR now and I'd approve it if I could! 😄

I also tweaked the docs to say, "The recommended version is Java 17 because it's the version we test with."

And in the dev guide I linked to the PR where we upgraded to Java 17:

@github-actions
Copy link

github-actions bot commented Jun 4, 2025

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:enforce-java-17
ghcr.io/gdcc/configbaker:enforce-java-17

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@pdurbin pdurbin added this to the 6.7 milestone Jun 4, 2025
@ofahimIQSS ofahimIQSS assigned ofahimIQSS and unassigned ofahimIQSS Jun 4, 2025
@ofahimIQSS ofahimIQSS moved this from Ready for QA ⏩ to QA ✅ in IQSS Dataverse Project Jun 4, 2025
@ofahimIQSS
Copy link
Contributor

All tests passed successfully across JDK 17, 21, and 23. No issues found with service loader files or runtime behavior. The PR fix works as intended.

Verified following JDKs (17.0.15-amzn, 21.0.7-amzn, 23.0.2-amzn), ensured that files were present.
edu.harvard.iq.dataverse.pidproviders.PidProviderFactory
org.eclipse.microprofile.config.spi.ConfigSourceProvider
io.gdcc.spi.export.Exporter

Merging.

@ofahimIQSS ofahimIQSS merged commit bb99c1a into develop Jun 4, 2025
16 checks passed
@ofahimIQSS ofahimIQSS deleted the enforce-java-17 branch June 4, 2025 17:13
@github-project-automation github-project-automation bot moved this from QA ✅ to Merged 🚀 in IQSS Dataverse Project Jun 4, 2025
@ofahimIQSS ofahimIQSS removed their assignment Jun 4, 2025
@pdurbin pdurbin moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Jun 5, 2025
@cmbz cmbz added the FY26 Sprint 4 FY26 Sprint 4 (2025-08-13 - 2025-08-27) label Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Code Infrastructure formerly "Feature: Code Infrastructure" Feature: Developer Guide FY26 Sprint 4 FY26 Sprint 4 (2025-08-13 - 2025-08-27) Size: 0.5 A percentage of a sprint. 0.35 hours Type: Bug a defect

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

8 participants