Skip to content

Fix forge dockerBuildNative logback init cascade from JGit - #15647

Merged
jamesfredley merged 1 commit into
apache:8.0.xfrom
jamesfredley:ci/forge-grm-version-bump
May 8, 2026
Merged

jamesfredley merged 1 commit into
apache:8.0.xfrom
jamesfredley:ci/forge-grm-version-bump

Conversation

@jamesfredley

Copy link
Copy Markdown
Contributor

Summary

PR #15646 was iteration 1 of fixing the Forge dockerBuildNative Cloud Run deploy failures. It moved the build past the original ch.qos.logback.* was unintentionally initialized at build time errors but introduced a second-order conflict: with our --initialize-at-run-time=ch.qos.logback,org.slf4j directive in place, the GraalVM Reachability Metadata Repository 1.4.9 entry's --initialize-at-build-time=ch.qos.logback directive started reporting the same logback classes as the class was requested to be initialized at run time ... got initialized during image building (see run 25574400224).

--trace-class-initialization showed the actual cascade source:

ch.qos.logback.core.CoreConstants the class was requested to be initialized at run time ...
  org.eclipse.jgit.transport.Transport caused initialization of this class with the following trace:
        at ch.qos.logback.core.CoreConstants.<clinit>(CoreConstants.java:48)

org.eclipse.jgit.transport.Transport (and most of the other Transport* classes) declares a static final Logger LOG field. Forcing them to --initialize-at-build-time in grails-forge-api/native-image.properties transitively runs LoggerFactory.<clinit> and the entire ch.qos.logback class graph at build time. This worked under logback 1.4.x because GRM 1.4.9 also marked ch.qos.logback as build-time, so they all got initialized together. Under logback 1.5.x the GRM entry is incomplete (additional 1.5.x classes are still expected at run time), and our explicit run-time override turns the cascade into a hard error.

This PR resolves it with two coordinated changes that together let dockerBuildNative succeed end-to-end locally for both modules:

1. Drop the manual JGit build-time-init list

grails-forge-api/.../native-image.properties used to force a long list of org.eclipse.jgit.* classes to --initialize-at-build-time. That list predates the GraalVM Reachability Metadata Repository entry for org.eclipse.jgit:org.eclipse.jgit (which now ships reflection and resource metadata covering jgit 6.5.0+ and our 6.10.x runtime). It is the cascade source for the logback build-time init and is no longer necessary - JGit can fall back to the default (run-time) class initialization. Only the existing --initialize-at-run-time=org.eclipse.jgit.lib.internal.WorkQueue entry remains (opposite direction, unrelated).

2. Pin the GRM repo zip version to 0.3.35

grails-forge-web-netty/build.gradle and grails-forge-analytics-postgres/build.gradle now set graalvmNative.metadataRepository.version = '0.3.35'. The version bundled with the Micronaut Gradle Application Plugin 4.6.2 selects the ch.qos.logback:logback-classic 1.4.9 metadata for our 1.5.17 runtime, whose --initialize-at-build-time=ch.qos.logback directive forces the conflict regardless of the JGit cascade. GRM 0.3.35 (released 2026-03-06) ships a 1.5.7 metadata directory covering 1.5.7 - 1.5.29 (so it covers 1.5.17), and that directory contains only reflect-config.json and resource-config.json - no --initialize-at-build-time directive - so logback initializes at the default (run-time) and the existing --initialize-at-run-time=ch.qos.logback,org.slf4j override from PR #15646 applies unopposed. GRM 1.x release zips use a new repository layout that the GraalVMReachabilityMetadataService bundled with the current plugin does not understand (NoSuchFileException: .../exploded/index.json), so we stay on the last compatible 0.3.x release with the updated logback metadata.

Verification

Reproduced locally on Docker 29.3.0 against the same ghcr.io/graalvm/native-image-community:21.0.2-ol9 image used by the Forge deploy workflows:

$ ./gradlew :grails-forge-web-netty:dockerBuildNative -PdockerImageName=grails-forge-local:web-netty
BUILD SUCCESSFUL in 2m 33s
Successfully tagged grails-forge-local:web-netty

$ docker run -d -p 18080:8080 grails-forge-local:web-netty
$ docker logs <id>
io.micronaut.runtime.Micronaut - Startup completed in 45ms. Server Running: http://...:8080

$ curl -s -o /dev/null -w "%{http_code}\n" http://localhost:18080/
200

$ ./gradlew :grails-forge-analytics-postgres:dockerBuildNative -PdockerImageName=grails-forge-local:analytics
BUILD SUCCESSFUL in 3m 24s
Successfully tagged grails-forge-local:analytics

$ docker run -d -p 18081:8080 grails-forge-local:analytics
# Native binary starts, reaches DB connection step (fails as expected without local Postgres):
# Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused.

Class-initialization conflicts gone, native binaries actually start, postgres driver runtime path exercised. CI checks (CI, RAT, CodeQL, code-style, Groovy joint validation) cover the rest; the deploy workflows are workflow_dispatch-only and will be re-triggered after this lands.

PR apache#15646 added --initialize-at-run-time=ch.qos.logback,org.slf4j to
override the GraalVM Reachability Metadata Repository 1.4.9 entry's
--initialize-at-build-time=ch.qos.logback directive, but
dockerBuildNative still failed: with --trace-class-initialization
enabled, native-image reports that org.eclipse.jgit.transport.Transport
caused build-time initialization of ch.qos.logback.core.CoreConstants
(and the rest of the logback class graph). Transport declares a
static final Logger LOG field, so forcing it to --initialize-at-
build-time in grails-forge-api/native-image.properties transitively
ran LoggerFactory.<clinit> and the whole logback init cascade at
build time, conflicting with our --initialize-at-run-time directive
on logback 1.5.x classes.

Two changes that together let dockerBuildNative succeed end-to-end
locally for both grails-forge-web-netty and grails-forge-analytics-
postgres on the Java 21 GraalVM Community 21.0.2-ol9 image, and let
the resulting native binaries actually start (web-netty serves HTTP
200 in 45ms; analytics-postgres reaches the postgres connection step):

1. Drop the manual --initialize-at-build-time list of jgit classes in
   grails-forge-api/src/main/resources/META-INF/native-image/org.grails.
   forge.api/grails-forge-api/native-image.properties. The list
   predates the GRM repo entry for org.eclipse.jgit, which now ships
   reflection and resource metadata covering jgit 6.5.0+; the manual
   list is the cascade source for the logback initialization at build
   time and is no longer necessary. Keep the existing one-class
   --initialize-at-run-time=org.eclipse.jgit.lib.internal.WorkQueue
   override (this one is opposite direction and unrelated).

2. Pin grails-forge-web-netty and grails-forge-analytics-postgres to
   GRM repo version 0.3.35 (released 2026-03-06) via
   graalvmNative.metadataRepository.version. The version bundled with
   the Micronaut Gradle Application Plugin 4.6.2 selects the
   logback-classic 1.4.9 metadata for our 1.5.17 runtime, whose
   --initialize-at-build-time=ch.qos.logback directive forces the
   conflict regardless of the JGit cascade. GRM 0.3.35 ships a 1.5.7
   metadata directory (covering 1.5.7-1.5.29, including our 1.5.17)
   that contains only reflection / resource configs and no
   --initialize-at-build-time directive, so logback initializes at
   the default (run-time) and our --initialize-at-run-time override
   applies unopposed. GRM 1.x release zips use a new repository
   layout that the GraalVMReachabilityMetadataService bundled with
   the current plugin does not understand, so we stay on the last
   compatible 0.3.x release with the updated logback metadata.

Verified locally with `./gradlew :grails-forge-web-netty:dockerBuildNative`
and `./gradlew :grails-forge-analytics-postgres:dockerBuildNative` on
Docker 29.3.0 against the Java 21 GraalVM Community 21.0.2-ol9 image
used by the Forge deploy workflows; both native binaries start.

Assisted-by: claude-code:claude-4.7-opus
Copilot AI review requested due to automatic review settings May 8, 2026 20:02
@jamesfredley
jamesfredley merged commit 6e79495 into apache:8.0.x May 8, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Grails Forge dockerBuildNative (GraalVM native-image) failures caused by conflicting class-initialization directives, specifically a logback init cascade triggered via JGit and an incompatible reachability-metadata selection for logback 1.5.x.

Changes:

  • Pins the GraalVM Reachability Metadata Repository (GRM) version to 0.3.35 for the Forge native-image builds to avoid the logback --initialize-at-build-time=ch.qos.logback conflict.
  • Removes the Forge API’s manual --initialize-at-build-time list for various org.eclipse.jgit.* classes, leaving only the existing runtime-init entry for WorkQueue.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
grails-forge/grails-forge-web-netty/build.gradle Pins GRM metadata repository version to avoid logback native-image init conflicts.
grails-forge/grails-forge-analytics-postgres/build.gradle Pins GRM metadata repository version to avoid logback native-image init conflicts.
grails-forge/grails-forge-api/src/main/resources/META-INF/native-image/org.grails.forge.api/grails-forge-api/native-image.properties Drops manual JGit build-time init list to prevent build-time logback initialization cascade.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +63 to +66
// that covers 1.5.7-1.5.29 and contains only reachability-metadata.json (no
// native-image.properties / no --initialize-at-build-time directive), so the
// conflict goes away and reflection metadata is still provided. GRM 1.x
// releases use a new repository layout that is incompatible with the
Comment on lines +64 to +69
// that covers 1.5.7-1.5.29 and contains only reachability-metadata.json (no
// native-image.properties / no --initialize-at-build-time directive), so the
// conflict goes away and reflection metadata is still provided. GRM 1.x
// releases use a new repository layout that is incompatible with the
// GraalVMReachabilityMetadataService bundled with this plugin, so we stay
// on the last 0.x release that contains the updated logback metadata.
jamesfredley added a commit that referenced this pull request May 8, 2026
After PR #15647 unblocked dockerBuildNative for grails-forge-
analytics-postgres, the resulting native binary built and pushed
successfully but the Cloud Run revision failed its startup probe
(`The user-provided container failed to start and listen on the
port defined provided by the PORT=8080 environment variable
within the allocated timeout`).

Reproducing locally with a postgres:15.3 sidecar showed the
binary crashing during datasource initialization:

  ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut
    server: Bean definition [javax.sql.DataSource] could not be
    loaded: Unsupported Database: PostgreSQL 15.3
  Caused by: org.flywaydb.core.api.FlywayException:
    Unsupported Database: PostgreSQL 15.3
        at org.flywaydb.core.internal.database.DatabaseTypeRegister
            .getDatabaseTypeForConnection(DatabaseTypeRegister.java:131)

Flyway 10.x split the per-database DatabaseType implementations
out of flyway-core into dedicated modules. After the May-2026
adoption of micronaut-platform pinned us to flyway-core 10.22.0,
the analytics service no longer had a PostgreSQL DatabaseType on
the runtime classpath, so Flyway's
`ServiceLoader<org.flywaydb.core.internal.database.DatabaseType>`
returned an empty match for the postgres connection and aborted
the schema migration. micronaut-flyway-bom:7.9.2 already manages
the matching `org.flywaydb:flyway-database-postgresql:10.22.0`
artifact, so adding it as `runtimeOnly` is sufficient.

Verified locally with a postgres:15.3 sidecar:

  HikariPool-1 - Start completed.
  Flyway - Database: jdbc:postgresql://...:5432/postgres (PostgreSQL 15.3)
  Flyway - Creating Schema History table "public"."flyway_schema_history"
  Flyway - Schema "public" is up to date. No migration necessary.
  io.micronaut.runtime.Micronaut - Startup completed in 193ms.
    Server Running: http://...:8080

Native binary now binds to PORT=8080 and serves HTTP within the
Cloud Run startup probe window.

Assisted-by: claude-code:claude-4.7-opus
jamesfredley added a commit that referenced this pull request May 8, 2026
After PR #15647 unblocked dockerBuildNative for grails-forge-
analytics-postgres, the resulting native binary built and pushed
successfully but the Cloud Run revision failed its startup probe
(`The user-provided container failed to start and listen on the
port defined provided by the PORT=8080 environment variable
within the allocated timeout`).

Reproducing locally with a postgres:15.3 sidecar showed the
binary crashing during datasource initialization:

  ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut
    server: Bean definition [javax.sql.DataSource] could not be
    loaded: Unsupported Database: PostgreSQL 15.3
  Caused by: org.flywaydb.core.api.FlywayException:
    Unsupported Database: PostgreSQL 15.3
        at org.flywaydb.core.internal.database.DatabaseTypeRegister
            .getDatabaseTypeForConnection(DatabaseTypeRegister.java:131)

Flyway 10.x split the per-database DatabaseType implementations
out of flyway-core into dedicated modules. After the May-2026
adoption of micronaut-platform pinned us to flyway-core 10.22.0,
the analytics service no longer had a PostgreSQL DatabaseType on
the runtime classpath, so Flyway's
`ServiceLoader<org.flywaydb.core.internal.database.DatabaseType>`
returned an empty match for the postgres connection and aborted
the schema migration. micronaut-flyway-bom:7.9.2 already manages
the matching `org.flywaydb:flyway-database-postgresql:10.22.0`
artifact, so adding it as `runtimeOnly` is sufficient.

Verified locally with a postgres:15.3 sidecar:

  HikariPool-1 - Start completed.
  Flyway - Database: jdbc:postgresql://...:5432/postgres (PostgreSQL 15.3)
  Flyway - Creating Schema History table "public"."flyway_schema_history"
  Flyway - Schema "public" is up to date. No migration necessary.
  io.micronaut.runtime.Micronaut - Startup completed in 193ms.
    Server Running: http://...:8080

Native binary now binds to PORT=8080 and serves HTTP within the
Cloud Run startup probe window.

Assisted-by: claude-code:claude-4.7-opus
jamesfredley added a commit that referenced this pull request May 8, 2026
…ntime

After PR #15647 + #15648 fixed dockerBuildNative + Cloud Run startup
for the analytics service, both Forge deploy workflows finally
finished green and pushed `next.grails.org` (8.0.0-M1 hotfix branch)
and `prev-snapshot.grails.org` (8.0.x) revisions live. start.grails.org
still does not list 8.0.0-M1 / 8.0-SNAPSHOT in the Grails Version
selector, though, because both backends return:

  $ curl -i -H 'Origin: https://start.grails.org' https://next.grails.org/versions
  HTTP/1.1 500 Internal Server Error
  Content-Type: application/json
  ...
  {"_embedded":{"errors":[{"message":"Internal Server Error: Error
   encoding object [org.grails.forge.api.VersionDTO@..] to JSON: No
   serializable introspection present for type VersionDTO. Consider
   adding Serdeable.Serializable annotate to type VersionDTO."}]},
   "message":"Internal Server Error"}

Reproduced locally (`docker run grails-forge-local:web-netty` against
the GraalVM Community 21.0.2-ol9 native image with CORS_ALLOWED_ORIGIN
set, then `curl -H 'Origin: https://start.grails.org' /versions`) -
identical 500.

Root cause: PR #15365 review feedback (commit e1f3013,
"Address PR review feedback: telemetry override, forge BOM
adoption, publish plugin bump") swapped grails-forge-web-netty's
runtime JSON dependency:

  -    runtimeOnly 'io.micronaut:micronaut-jackson-databind'
  +    runtimeOnly 'io.micronaut.serde:micronaut-serde-jackson'

with the rationale that "the forge stack is a Micronaut 4 serde-
jackson application; the legacy jackson-databind runtime was a
copy-paste from an earlier generator template". That is not yet
true: every DTO returned by the Forge controllers
(VersionDTO, ApplicationTypeDTO, FeatureDTO, FeatureList,
SelectOptionsDTO, GormImplDTO, JdkVersionDTO, LanguageDTO,
ServletImplDTO, DevelopmentReloadingDTO, GitHubCreateDTO,
PreviewDTO, ApplicationTypeList, LinkDTO, the abstract Linkable
parent, ...) carries `@Introspected` only - none of them are
`@Serdeable` or registered via `@SerdeImport`. Micronaut Serde
correctly rejects @Introspected-only classes at runtime, while
Micronaut Jackson Databind serialises them via Jackson + bean
introspection. The mismatch turns every JSON endpoint behind
next.grails.org and prev-snapshot.grails.org into a 500, which
is why Forge UI's `versions` fetch is empty for those backends
and 8.0.0-M1 is missing from the start.grails.org Grails Version
selector.

The other Forge modules (forge-api tests, forge-core, analytics-
postgres) all still use micronaut-jackson-databind; web-netty
was the only inconsistency. Restore web-netty to
micronaut-jackson-databind so the runtime matches the rest of the
forge stack and the existing @introspected DTOs serialise. A
proper end-to-end Serde migration belongs in a separate PR that
also annotates every Forge DTO with @Serdeable / @SerdeImport.

Verified locally on Docker 29.3.0 with the same Java 21 GraalVM
Community 21.0.2-ol9 native-image container the deploy workflows
use:

  $ curl -i -H 'Origin: https://start.grails.org' http://localhost:18080/versions
  HTTP/1.1 200 OK
  Access-Control-Allow-Origin: https://start.grails.org
  Vary: Origin
  Access-Control-Allow-Credentials: true
  content-type: application/json
  ...
  {"_links":{"self":{"href":"http://.../versions","templated":false}},
   "versions":{...,"grails.version":"8.0.0-M1",...}}

  $ curl -i -H 'Origin: https://start.grails.org' http://localhost:18080/select-options
  HTTP/1.1 200 OK
  Access-Control-Allow-Origin: https://start.grails.org
  ...

Endpoints serve JSON cleanly; CORS allow-origin header is present;
the start.grails.org Grails Version selector will pick up 8.0.0-M1
once next.grails.org is redeployed from this commit.

Assisted-by: claude-code:claude-4.7-opus
jamesfredley added a commit that referenced this pull request May 8, 2026
…ntime

After PR #15647 + #15648 fixed dockerBuildNative + Cloud Run startup
for the analytics service, both Forge deploy workflows finally
finished green and pushed `next.grails.org` (8.0.0-M1 hotfix branch)
and `prev-snapshot.grails.org` (8.0.x) revisions live. start.grails.org
still does not list 8.0.0-M1 / 8.0-SNAPSHOT in the Grails Version
selector, though, because both backends return:

  $ curl -i -H 'Origin: https://start.grails.org' https://next.grails.org/versions
  HTTP/1.1 500 Internal Server Error
  Content-Type: application/json
  ...
  {"_embedded":{"errors":[{"message":"Internal Server Error: Error
   encoding object [org.grails.forge.api.VersionDTO@..] to JSON: No
   serializable introspection present for type VersionDTO. Consider
   adding Serdeable.Serializable annotate to type VersionDTO."}]},
   "message":"Internal Server Error"}

Reproduced locally (`docker run grails-forge-local:web-netty` against
the GraalVM Community 21.0.2-ol9 native image with CORS_ALLOWED_ORIGIN
set, then `curl -H 'Origin: https://start.grails.org' /versions`) -
identical 500.

Root cause: PR #15365 review feedback (commit e1f3013,
"Address PR review feedback: telemetry override, forge BOM
adoption, publish plugin bump") swapped grails-forge-web-netty's
runtime JSON dependency:

  -    runtimeOnly 'io.micronaut:micronaut-jackson-databind'
  +    runtimeOnly 'io.micronaut.serde:micronaut-serde-jackson'

with the rationale that "the forge stack is a Micronaut 4 serde-
jackson application; the legacy jackson-databind runtime was a
copy-paste from an earlier generator template". That is not yet
true: every DTO returned by the Forge controllers
(VersionDTO, ApplicationTypeDTO, FeatureDTO, FeatureList,
SelectOptionsDTO, GormImplDTO, JdkVersionDTO, LanguageDTO,
ServletImplDTO, DevelopmentReloadingDTO, GitHubCreateDTO,
PreviewDTO, ApplicationTypeList, LinkDTO, the abstract Linkable
parent, ...) carries `@Introspected` only - none of them are
`@Serdeable` or registered via `@SerdeImport`. Micronaut Serde
correctly rejects @Introspected-only classes at runtime, while
Micronaut Jackson Databind serialises them via Jackson + bean
introspection. The mismatch turns every JSON endpoint behind
next.grails.org and prev-snapshot.grails.org into a 500, which
is why Forge UI's `versions` fetch is empty for those backends
and 8.0.0-M1 is missing from the start.grails.org Grails Version
selector.

The other Forge modules (forge-api tests, forge-core, analytics-
postgres) all still use micronaut-jackson-databind; web-netty
was the only inconsistency. Restore web-netty to
micronaut-jackson-databind so the runtime matches the rest of the
forge stack and the existing @introspected DTOs serialise. A
proper end-to-end Serde migration belongs in a separate PR that
also annotates every Forge DTO with @Serdeable / @SerdeImport.

Verified locally on Docker 29.3.0 with the same Java 21 GraalVM
Community 21.0.2-ol9 native-image container the deploy workflows
use:

  $ curl -i -H 'Origin: https://start.grails.org' http://localhost:18080/versions
  HTTP/1.1 200 OK
  Access-Control-Allow-Origin: https://start.grails.org
  Vary: Origin
  Access-Control-Allow-Credentials: true
  content-type: application/json
  ...
  {"_links":{"self":{"href":"http://.../versions","templated":false}},
   "versions":{...,"grails.version":"8.0.0-M1",...}}

  $ curl -i -H 'Origin: https://start.grails.org' http://localhost:18080/select-options
  HTTP/1.1 200 OK
  Access-Control-Allow-Origin: https://start.grails.org
  ...

Endpoints serve JSON cleanly; CORS allow-origin header is present;
the start.grails.org Grails Version selector will pick up 8.0.0-M1
once next.grails.org is redeployed from this commit.

Assisted-by: claude-code:claude-4.7-opus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants