# Error in apm java agent when using latest javalin versions

**URL:** <https://discuss.elastic.co/t/error-in-apm-java-agent-when-using-latest-javalin-versions/371702>\
**Category:** APM\
**Tags:** java\
**Created:** [December 9, 2024, 1:28pm UTC](https://discuss.elastic.co/t/error-in-apm-java-agent-when-using-latest-javalin-versions/371702 "2024-12-09T13:28:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ukarim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ukarim/32/139751_2.png) [@ukarim](https://discuss.elastic.co/u/ukarim)\
**Post date:** [December 9, 2024, 1:28pm UTC](https://discuss.elastic.co/t/error-in-apm-java-agent-when-using-latest-javalin-versions/371702/1 "2024-12-09T13:28:31Z")

</div>

**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)**:

```2024-12-09
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]

```

---

<div class="post-metadata">

**Author:** ![Jonas\_Kunz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_kunz/32/110740_2.png) [@Jonas\_Kunz](https://discuss.elastic.co/u/Jonas_Kunz)\
**Post date:** [December 9, 2024, 2:23pm UTC](https://discuss.elastic.co/t/error-in-apm-java-agent-when-using-latest-javalin-versions/371702/2 "2024-12-09T14:23:12Z")

</div>

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](https://github.com/elastic/apm-agent-java/issues/3908).

> 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.
