Error in apm java agent when using latest javalin versions

APM Agent language and version:

APM java agent. Latest stable version (co.elastic.apm:elastic-apm-agent:1.52.1)

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

Latest version of the apm-javalin-plugin is built using javalin version 4.2.0. As you can see here https://javalin.io/migration-guide-javalin-4-to-5, version 5 has introduced some incompatibilities. For example, io.javalin.http.Context has been transformed to interface. As a result we can't use apm java agent in projects with new versions of javalin.

Is there any plans to update javalin version in apm-javalin-plugin? May I create a pull requests and try to fix this?

Steps to reproduce:

  1. create simple javalin project using javalin version 5.x.x or higher
  2. setup apm java agent using -javaagent flag
  3. java.lang.IncompatibleClassChangeError in logs

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

java.lang.IncompatibleClassChangeError: Found interface io.javalin.http.Context, but class was expected
  at co.elastic.apm.agent.javalin.JavalinInstrumentation$HandlerAdapterAdvice.setSpanAndTransactionName(JavalinInstrumentation.java:177) ~[elastic-apm-agent.jar:1.52.1]
  at xx.xxxxx.xxxxxx.xxxxxxx.xxxxx.TestFilter.handle(TestFilter.java:40) ~[test-1.0.0-SNAPSHOT.jar:?]
  at io.javalin.router.Endpoint.handle(Endpoint.kt:52) ~[javalin-6.1.3.jar:6.1.3]
  at io.javalin.router.ParsedEndpoint.handle(ParsedEndpoint.kt:15) ~[javalin-6.1.3.jar:6.1.3]

Thanks for reporting this! Usually we try to keep up with the updates for supported frameworks, looks like we missed on this one.

We'll try to fix it soon to-mid term, you can follow this issue.

May I create a pull requests and try to fix this?

Contributions are always welcome! This one might be a bit more difficult than it seems though, because the agent also needs to remain backwards compatible for the older versions of javalin.