Spring MVC View instrumentation incorrectly matches static render overloads (EasyPOI)
Maintainers usually reply within 1 day
@VelpulaGangavardhan is already working on this.
Since Oct 16, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, observability
Research direction
The matcher is in apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-spring5/src/main/java/co/elastic/apm/agent/springwebmvc/ViewRenderInstrumentation.java, in getMethodMatcher(), and beforeExecute() shows why the instance is required. Read both, then add regression tests for a View subtype with a static four-argument render overload and for normal three-argument instance rendering. Done when the static overload loads without a transformation error, the instance path still creates its span, and exceptions still close the span.
Written by the indexing model from the issue text.
Description
Describe the bug
Elastic APM Java agent 1.57.0 fails to transform EasyPOI's cn.afterturn.easypoi.view.PoiBaseView. Its Spring MVC View instrumentation also matches a static four-argument render overload, but the advice requires an instance (@Advice.This).
Observed warning:
WARN co.elastic.apm.agent.bci.bytebuddy.ErrorLoggingListener - Error on transformation cn.afterturn.easypoi.view.PoiBaseView
java.lang.IllegalStateException: Cannot map this reference for static method or constructor start:
public static void cn.afterturn.easypoi.view.PoiBaseView.render(java.util.Map,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.String)
The application continues starting, but this class transformation fails. The failure happens during instrumentation; an invocation of the static helper is not necessary to explain the binding error.
Relevant versions: Java 8; Spring Framework 4.3.20.RELEASE; Elastic APM Java agent 1.57.0.
Steps to reproduce
The following synthetic class illustrates the affected method shape without requiring EasyPOI. This standalone reproduction has not yet been independently executed; the reported warning above was observed with PoiBaseView.
package example;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.view.AbstractView;
public abstract class OverloadedView extends AbstractView {
public static void render(Map<String, ?> model,
HttpServletRequest request,
HttpServletResponse response,
String viewName) {
// A convenience overload, not the View instance method.
}
}
- Include Spring MVC and the Servlet API, compile this class, and start with agent 1.57.0 and
spring-view-renderenabled. - Load the class, for example with
Class.forName("example.OverloadedView"). - The type matches because it implements Spring's
ViewthroughAbstractView. Its static overload also matches the current method matcher, causing@Advice.Thisbinding to fail.
EasyPOI's public implementation has the same signature: PoiBaseView source.
Expected behavior
Only the intended non-static, three-argument View.render(Map, HttpServletRequest, HttpServletResponse) implementation should receive this advice. Static convenience overloads should be ignored, and normal Spring MVC View rendering should remain instrumented.
Source analysis
The same matcher is present in main at commit 5cabf9ceeaea99f7a811b896064bf7aa8b131e5d (source inspected; that commit was not runtime-tested):
getMethodMatcher()checks the namerenderand the first three argument types, but does not constrain the argument count or exclude static methods.beforeExecuterequires@Advice.Thisand uses the instance to determine the span subtype.
A possible fix is to add not(isStatic()) and takesArguments(3) to the matcher, preserving the existing javax/jakarta argument checks. Suggested regression coverage:
- A View subtype with the static four-argument overload above loads without a transformation error.
- Normal three-argument instance rendering still produces the expected span.
- Exceptions during normal rendering still close the span correctly.
This differs from #2896, which fixes a null View name rather than binding instance advice to a static method.
Workaround
Exclude cn.afterturn.easypoi.view.PoiBaseView using classes_excluded_from_instrumentation, or disable spring-view-render if losing all Spring View rendering spans is acceptable. HTTP request tracing can remain enabled separately.
- Dominant language
- Java
- Stars
- 593
- Forks
- 338
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 13
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from elastic/apm-agent-java
-
agent-java
Difficulty 2/5 1-2 days Newbie friendliness 62/100
elastic/apm-agent-java#2844 · 2 comments ·
Maintainers usually reply within 1 day
-
Improve docs and add error log related to illegal activation of transactionPossibly taken @AzazelSensei claimed this 39 days ago. Opendocs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
elastic/apm-agent-java#850 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
agent-java community triage
Difficulty 3/5 1-2 days Newbie friendliness 55/100
elastic/apm-agent-java#4593 ·
Maintainers usually reply within 1 day
-
agent-java community triage
elastic/apm-agent-java#4573 · 4 comments ·
Maintainers usually reply within 1 day
-
agent-java
Difficulty 4/5 3-5 days Newbie friendliness 55/100
elastic/apm-agent-java#4549 ·
Maintainers usually reply within 1 day
All issues in elastic/apm-agent-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Vakore/ZappierGames#147 ·
-
spigotmc
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Dans-Plugins/Wild-Pets#356 ·
Maintainers usually reply within 1 day
-
spigotmc
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Dans-Plugins/Medieval-Roleplay-Engine#371 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
eddyizm/tempus#1220 · 1 comment ·
Maintainers usually reply within 2 days
-
ReplaceSchema画面のSQL表示で先頭/末尾に余分な空白が入るPossibly taken A pull request linked to this issue is open or already merged. Openbug javascript
Difficulty 1/5 Under an hour Newbie friendliness 95/100
dbflute/dbflute-intro#690 ·
Maintainers usually reply within 1 day