Skip to content

fix: bundle SLF4J runtime deps for GeometryMappingJob standalone JVM#47

Merged
rohitc-1998 merged 1 commit into
masterfrom
DEV/fix-geometry-mapping-slf4j-classpath
May 14, 2026
Merged

fix: bundle SLF4J runtime deps for GeometryMappingJob standalone JVM#47
rohitc-1998 merged 1 commit into
masterfrom
DEV/fix-geometry-mapping-slf4j-classpath

Conversation

@rohitc-1998
Copy link
Copy Markdown

Summary

Fixes the NoClassDefFoundError: org/slf4j/LoggerFactory that crashes the Geometry Mapping phase of run-tile-pipeline.sh, seen on the dev cluster as exit-1 from
valhalla-tile-pipeline after the :development-latest image was refreshed and the phase started executing for the first time.

Root cause

The published valhalla-jni-*.jar is intentionally thin — project classes + native libs only — so Spring Boot consumers like tada-routing-service can bring their own
transitive deps. But deploy/scripts/run-tile-pipeline.sh runs the geometry mapping job as a standalone JVM process:

java -cp /app/valhalla-jni.jar global.tada.valhalla.traffic.sg.GeometryMappingJob

With only the thin JAR on the classpath, GeometryMappingJob.kt:46's LoggerFactory.getLogger(...) throws NoClassDefFoundError on the static initializer — the class never
loads, the JVM exits 1, and the pipeline's geometry mapping step bails before it can write geometry_mapping.json to EFS.

Changes

  • libs.versions.toml — add slf4j-simple library alias.
  • build.gradle.kts — add runtimeOnly(libs.slf4j.simple) (only for the standalone JVM path; Spring Boot consumers bring their own SLF4J binding via their own
    runtimeClasspath and don't see runtimeOnly). Register a new copyRuntimeDeps task — explicitly invoked from Dockerfile.prod, not wired to jar/assemble so maven
    consumers don't pay for it.
  • Dockerfile.prod — invoke copyRuntimeDeps alongside build; copy build/libs/runtime/*.jar into /app/lib/.
  • run-tile-pipeline.sh — extend the java -cp from "${jar}" to "${jar}:/app/lib/*".

Verification

Tested locally before committing:

  • ./gradlew tasks --all lists copyRuntimeDeps under Build tasks with the right description ✓

  • ./gradlew copyRuntimeDeps writes 7 jars to build/libs/runtime/:

    • slf4j-api-2.0.16.jar
    • slf4j-simple-2.0.16.jar
    • kotlin-stdlib-2.0.21.jar
    • kotlin-reflect-2.0.21.jar
    • kotlinx-coroutines-core-jvm-1.9.0.jar
    • json-20240303.jar
    • annotations-23.0.0.jar

    Project's own valhalla-jni-*.jar is not included (Gradle's runtimeClasspath excludes the project's own output by convention — confirmed empirically). ✓

  • End-to-end class load check:

    java -cp valhalla-jni-1.0.0-SNAPSHOT.jar:build/libs/runtime/* \
         global.tada.valhalla.traffic.sg.GeometryMappingJob
    Now logs cleanly via SLF4J:

[main] INFO global.tada.valhalla.traffic.sg.GeometryMappingJob - === Geometry Mapping Job starting ===
[main] ERROR global.tada.valhalla.traffic.sg.GeometryMappingJob - VALHALLA_TILE_DIR environment variable is required
The ERROR is the expected fail-fast — VALHALLA_TILE_DIR is set in production by the pipeline; here it's just proving the class loads, LoggerFactory is reachable, and the
binding emits to stderr. Before this fix, neither line appeared because the class never loaded. ✓

  • bash -n deploy/scripts/run-tile-pipeline.sh — syntax clean ✓

Impact on existing consumers

The published valhalla-jni-*.jar keeps its name, coordinates and contents. tada-routing-service's vendored copy at libs/valhalla-jni-1.0.0-SNAPSHOT.jar is unaffected by this
change.

Follow-up after merge

  1. Image build workflow rebuilds :development-latest (~12–15 min).
  2. Re-trigger the valhalla-tile-pipeline Job from Argo.
  3. Expected: Job runs ~20–30 min total; geometry_mapping.json lands on EFS at /mnt/efs/valhalla_tiles/singapore/cache/.
  4. Next tada-traffic-data-builder cron tick produces traffic.tar — completing the LTA traffic integration end-to-end on dev.

@rohitc-1998 rohitc-1998 merged commit 4f4b3b4 into master May 14, 2026
12 of 13 checks passed
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.

3 participants