Skip to content

fix(runtime): javac -parameters + fallback ObjectMapper bean#3

Merged
jlc488 merged 1 commit into
mainfrom
feat/runtime-fixes
May 26, 2026
Merged

fix(runtime): javac -parameters + fallback ObjectMapper bean#3
jlc488 merged 1 commit into
mainfrom
feat/runtime-fixes

Conversation

@jlc488
Copy link
Copy Markdown
Contributor

@jlc488 jlc488 commented May 26, 2026

Summary

First runtime test (./gradlew :devslab-kit-sample-app:test against Testcontainers Postgres + Redis) surfaced two issues that the compile-only verification in PR #1/#2 had no way to catch.

1. AOT processing failed (processTestAot)

IllegalArgumentException: MethodParameter.getParameterName() must not be null
  at MethodMetadata.initializeMethodArguments
  at AotRepositoryCreator.create

Triggered by JpaPlatformPermissionRepository.findCodesForUserId(@Param("userId") UUID userId). Spring Data JPA's AOT repository generator needs parameter names to survive into bytecode.

Fix: add -parameters to javac via root subprojects {} convention.

2. ApplicationContext refresh failed

NoSuchBeanDefinitionException: No qualifying bean of type 'com.fasterxml.jackson.databind.ObjectMapper'
  injected into 'auditLogService' (AuditAutoConfiguration)

JacksonAutoConfiguration didn't activate in Spring Boot 4 with our current dependency graph (spring-boot-starter-webmvc no longer pulls it transitively the way starter-web did in 3.x).

Fix: register @ConditionalOnMissingBean ObjectMapper fallback in AuditAutoConfiguration. Consumers that bring their own (Spring Boot Jackson autoconfig, custom mapper, etc.) still win via the conditional.

Verified

./gradlew :devslab-kit-sample-app:test  → BUILD SUCCESSFUL in 51s
  • ApplicationContext boots cleanly
  • All 8 starter beans autowire (TenantResolver, TenantContextHolder, CurrentUserProvider, PasswordHasher, LocalLoginService, PermissionChecker, MenuProvider, AuditEventPublisher)
  • Flyway V1–V4 migrate against real Postgres
  • BCrypt hash + match round-trip

Known non-fatal warning (deferred follow-up)

Spring Data Redis tries to classify our JPA repos as RedisHash candidates because we depend on spring-data-redis. Will silence with spring.data.redis.repositories.enabled=false in a later commit (planning §12 Redis usage).

Two runtime-only blockers found by ./gradlew :devslab-kit-sample-app:test
(compile was always green, so neither showed up earlier):

1. Spring Data JPA AOT processor (`processTestAot`) failed with
   `IllegalArgumentException: MethodParameter.getParameterName() must not be null`
   when trying to generate AOT code for the @Param("userId") native query on
   JpaPlatformPermissionRepository.findCodesForUserId. Spring Data needs
   parameter names to survive into bytecode; the default javac in our
   subprojects {} convention was emitting them.
   Fix: add `options.compilerArgs.add("-parameters")` to
   `tasks.withType<JavaCompile>().configureEach` in the root convention.

2. ApplicationContext refresh failed with NoSuchBeanDefinitionException for
   ObjectMapper, requested by `auditLogService` in AuditAutoConfiguration.
   Spring Boot 4 didn't activate JacksonAutoConfiguration in our setup
   (likely because spring-boot-starter-webmvc no longer pulls it transitively
   the way starter-web did in 3.x). Rather than chasing the starter graph,
   register a `@ConditionalOnMissingBean ObjectMapper` fallback in
   AuditAutoConfiguration; consumer apps that already expose an ObjectMapper
   (e.g. via Jackson autoconfig) win via the conditional.

Verified: ./gradlew :devslab-kit-sample-app:test now passes (51s):
  - ApplicationContext boots cleanly
  - All 8 starter beans autowire (TenantResolver, TenantContextHolder,
    CurrentUserProvider, PasswordHasher, LocalLoginService,
    PermissionChecker, MenuProvider, AuditEventPublisher)
  - Flyway V1–V4 migrate against real Postgres (Testcontainers)
  - BCrypt round-trip works

Warning still observed (non-fatal, deferred): Spring Data Redis tries to
classify our JPA repositories as RedisHash candidates because we pull in
spring-data-redis. Will silence with `spring.data.redis.repositories.enabled=false`
in a follow-up.
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