Skip to content

Fix aot-basic example: timer header regression and native-image reflection gaps - #198

Open
Croway wants to merge 3 commits into
mainfrom
fix/aot-basic-timer-header-regression
Open

Fix aot-basic example: timer header regression and native-image reflection gaps#198
Croway wants to merge 3 commits into
mainfrom
fix/aot-basic-timer-header-regression

Conversation

@Croway

@Croway Croway commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixed ${header.CamelTimerFiredTime} resolving to an empty string in all three routes (Java/YAML/XML DSL). camel-timer stopped populating the fired-time/metadata headers by default in Camel 4.1 (CAMEL-19817); the fix adds includeMetadata=true to each timer endpoint, matching the pattern already used in the kafka-oauth example.
  • Fixed native-image support, which was previously untested in this example (no GraalVM available locally at the time). Building with a current GraalVM (25.3.4 CE) failed at runtime with MissingReflectionRegistrationError for several Camel-internal classes instantiated via reflection outside of Spring AOT's visibility (type converter loaders, the Simple/Constant languages, the timer/bean components, XML/YAML route loaders, etc.), plus a missing SPI resource (resource-resolver/source) and an unsupported UTF-32BE charset used by snakeyaml. Added reflect-config.json/resource-config.json (generated via the GraalVM tracing agent) and a native-image.properties enabling -H:+AddAllCharsets under META-INF/native-image so mvn -Pnative native:compile now produces a working native executable.
  • Refreshed the README sample output, which was stale (Spring Boot 3.1.0 / Camel 4.0.0-SNAPSHOT), to match the current Spring Boot 4.1.1 / Camel 4.23.0-SNAPSHOT versions and current timings, and simplified the GraalVM install steps since recent distributions bundle native-image by default.

Test plan

  • mvn spring-boot:run (JVM mode) — all three routes log a real timestamp for ${header.CamelTimerFiredTime}
  • java -jar target/camel-example-spring-boot-aot-basic-*.jar — same, ~1.2s startup
  • mvn -Pnative native:compile with GraalVM CE 25.3.4 (installed via sdkman) — builds successfully
  • Running the built native executable — starts successfully, all three routes log real timestamps, Camel context starts in ~1ms, app ready in ~66-82ms
  • Repeated clean build (mvn clean + native rebuild + run) to confirm reproducibility

🤖 Generated with Claude Code

https://claude.ai/code/session_01EV52HxRX2Ws2u8m575mmpv

…ction gaps

The three routes (Java, YAML, XML DSL) logged an empty string for
${header.CamelTimerFiredTime} instead of the timestamp shown in the README.
camel-timer stopped populating fired-time/metadata headers by default in
Camel 4.1 (CAMEL-19817); fix by adding includeMetadata=true to each timer
endpoint, matching the pattern already used in the kafka-oauth example.

Also fixed native-image support, which was previously untested (no local
GraalVM). Building with a current GraalVM (25.3.4 CE) failed at runtime with
MissingReflectionRegistrationError for several Camel-internal classes that
are instantiated via reflection outside of Spring AOT's visibility (type
converter loaders, the Simple/Constant languages, the timer/bean components,
XML/YAML route loaders, etc.), plus a missing SPI resource
(resource-resolver/source) and an unsupported UTF-32BE charset used by
snakeyaml. Added reflect-config.json/resource-config.json (generated via the
GraalVM tracing agent) and a native-image.properties enabling
-H:+AddAllCharsets under META-INF/native-image so `mvn -Pnative
native:compile` produces a working native executable.

Verified: JVM mode (mvn spring-boot:run and java -jar) and native mode
(mvn -Pnative native:compile followed by running the built executable) all
show real timestamps and start successfully, native image starting in ~1ms
of Camel context startup / ~66ms total.

Updated the stale README sample output (Spring Boot 3.1.0 / Camel
4.0.0-SNAPSHOT) to match the current Spring Boot 4.1.1 / Camel
4.23.0-SNAPSHOT versions and current timings, and simplified the GraalVM
install steps since recent distributions bundle native-image by default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EV52HxRX2Ws2u8m575mmpv
@Croway
Croway marked this pull request as draft September 3, 2026 17:38
Croway and others added 2 commits September 3, 2026 19:48
…etadata.json

Replace the classic split reflect-config.json/resource-config.json with the
single reachability-metadata.json format GraalVM now prefers, and rename the
sibling META-INF/native-image directory (previously only holding the
charsets native-image.properties) to reflect that it now also carries this
merged reflection/resource metadata.

Kept it in a sibling artifact-id directory rather than the example's own
(org.apache.camel.springboot.example/camel-example-spring-boot-aot-basic)
because Spring AOT's process-aot goal generates its own
reachability-metadata.json at that exact path; placing another file there
would risk collision during the resource merge into target/classes.

Verified with a clean mvn -Pnative native:compile followed by running the
built executable: all three routes still start and log real timestamps.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EV52HxRX2Ws2u8m575mmpv
Add a concise recipe to the README (tracing agent, diffing against what
Spring AOT and the dependency jars already cover, iterating native builds
against the exact GraalVM error messages) so the reachability-metadata.json
can be regenerated when the Spring Boot/Camel/GraalVM versions change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EV52HxRX2Ws2u8m575mmpv
@Croway
Croway marked this pull request as ready for review September 4, 2026 07:29
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.

2 participants