Spring Boot 4.0 / Spring Framework 7.0 Incompatibility with Elastic APM Java Agent

**Kibana version:** N/A (issue occurs during instrumentation)

**Elasticsearch version:** N/A (issue occurs during instrumentation)

**APM Server version:** N/A (issue occurs during instrumentation)

**APM Agent language and version:**

- Java 21

- elastic-apm-agent-1.55.2.jar

**Browser version:** N/A

**Original install method (e.g. download page, yum, deb, from source, etc.) and version:**

- Elastic APM Java Agent deployed via `-javaagent` JVM argument

- Version: 1.55.2 (latest available as of December 15, 2025)

**Fresh install or upgraded from other version?**

- Upgraded from Spring Boot 3.5.8 to 4.0.0

- Upgraded from Spring Cloud Gateway 4.3.0 to 5.0.0

- Upgraded from Spring Framework 6.1.x to 7.0.1

- APM agent version remained at 1.55.2

**Is there anything special in your setup?**

- Spring Cloud Gateway (WebFlux-based reactive gateway)

- Spring Boot 4.0.0 with Spring Framework 7.0.1

- Java 21

- Reactive WebFlux stack (not servlet-based)

**Description of the problem including expected versus actual behavior:**

**Expected:** Application starts successfully and processes HTTP requests with Elastic APM agent instrumentation enabled, capturing WebFlux request traces.

**Actual:** Application starts successfully but throws `NoSuchMethodError` on every incoming HTTP request when APM agent attempts to instrument Spring WebFlux `DispatcherHandler`. The error occurs because the APM agent expects the old `HttpHeaders.get(String)` method signature that returns `List`, but Spring Framework 7.0.1 changed this to return `String`. Requests fail to process correctly.

**Root Cause:** Spring Framework 6.2+ (released November 2024) introduced a breaking change to the `HttpHeaders` API. The APM agent 1.55.2 was compiled against the old API and is incompatible with Spring Framework 6.2+ / 7.0+.

**Steps to reproduce:**

1. Use Spring Boot 4.0.0 (which includes Spring Framework 7.0.1)

2. Use Spring Cloud Gateway with WebFlux (`spring-cloud-starter-gateway-server-webflux` or `spring-cloud-starter-gateway`)

3. Attach Elastic APM Java Agent 1.55.2 via JVM argument: `-javaagent:/path/to/elastic-apm-agent-1.55.2.jar`

4. Start the application (starts successfully)

5. Send any HTTP request to the application

6. Request processing fails with `NoSuchMethodError` in `DispatcherHandlerInstrumentation`

**Errors in browser console (if relevant):** N/A

**Provide logs and/or server output (if relevant):**

2025-12-15 16:30:44,279 [parallel-1] ERROR co.elastic.apm.agent.bci.IndyBootstrap - Advice threw an exception, this should never happen!
java.lang.NoSuchMethodError: 'java.util.List org.springframework.http.HttpHeaders.get(java.lang.Object)'
at co.elastic.apm.agent.springwebflux.DispatcherHandlerInstrumentation$HandleAdvice.onEnter(DispatcherHandlerInstrumentation.java:64) ~[elastic-apm-agent-1.55.2.jar:1.55.2]
at org.springframework.web.reactive.DispatcherHandler.handle(DispatcherHandler.java:139) ~[spring-webflux-7.0.1.jar!/:7.0.1]
at org.springframework.web.server.handler.DefaultWebFilterChain.lambda$filter$0(DefaultWebFilterChain.java:107) ~[spring-web-7.0.1.jar!/:7.0.1]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:46) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:75) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:54) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:75) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:56) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:75) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:54) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.Mono.subscribe(Mono.java:4569) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:83) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:301) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:301) ~[reactor-core-3.8.0.jar!/:3.8.0]
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:156) ~[reactor-core-3.8.0.jar!/:3.8.0]
... (truncated for brevity)

Hi !

Spring Boot 4.x and Spring Framework 7.x are not supported.

As an alternative, you should however try with an OpenTelemetry-based agent like EDOT Java.
I would also recommend to read the migration section of the documentation to help you with migrating to it.

Quick response! Thank you so much for letting me know!