Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Spring MVC View instrumentation incorrectly matches static render overloads (EasyPOI)

Open Beginner friendly
#4,594 1 comment 0 reactions 0 assignees View on GitHub

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
Tech stack
java, spring

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

agent-java community triage

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.
    }
}
  1. Include Spring MVC and the Servlet API, compile this class, and start with agent 1.57.0 and spring-view-render enabled.
  2. Load the class, for example with Class.forName("example.OverloadedView").
  3. The type matches because it implements Spring's View through AbstractView. Its static overload also matches the current method matcher, causing @Advice.This binding 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 name render and the first three argument types, but does not constrain the argument count or exclude static methods.
  • beforeExecute requires @Advice.This and 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from elastic/apm-agent-java

All issues in elastic/apm-agent-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.