APM Java agent for Micronaut applications?

We've tried to add the agent to a Micronaut application and we get a stack trace on startup (and application fails to run). Is this a known problem?

-XX:InitialHeapSize=536870912 -XX:MaxHeapSize=3221225472 -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
2020-06-30 18:27:19.270 [main] INFO co.elastic.apm.agent.util.JmxUtils - Found JVM-specific OperatingSystemMXBean interface: com.sun.management.OperatingSystemMXBean
2020-06-30 18:27:19.294 [elastic-apm-server-healthcheck] INFO co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server is available: {"ok":{"build_date":"2020-03-18T22:19:26Z","build_sha":"5371b55f98ffdedadc03a725d446b8a20b30b3ad","version":"6.8.8"}}
2020-06-30 18:27:19.433 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.16.0 as Application on Java 1.8.0_191 (Oracle Corporation) Mac OS X 10.15.5
2020-06-30 18:27:19.433 [main] WARN co.elastic.apm.agent.configuration.StartupInfo - To enable all features and to increase startup times, please configure application_packages
2020-06-30 18:27:19.449 [main] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state
18:27:21.406 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Error loading service [icd.$Application$ApplicationEventListener$onStartUp1$InterceptedDefinitionClass]: Stack map does not match the one at exception handler 97
Exception Details:
    icd/$Application$ApplicationEventListener$onStartUp1$InterceptedDefinitionClass.getAnnotationMetadata()Lio/micronaut/core/annotation/AnnotationMetadata; @97: astore_3
    Type 'io/micronaut/core/annotation/AnnotationMetadata' (current frame, locals[1]) is not assignable to 'co/elastic/apm/agent/impl/transaction/AbstractSpan' (stack map, locals[1])
  Current Frame:
    bci: @86
    flags: { }
    locals: { 'icd/$Application$ApplicationEventListener$onStartUp1$InterceptedDefinitionClass', 'io/micronaut/core/annotation/AnnotationMetadata', 'icd/$Application$ApplicationEventListener$onStartUp1$InterceptedDefinitionClass' }
    stack: { 'java/lang/Throwable' }
  Stackmap Frame:
    bci: @97
    flags: { }
    locals: { 'icd/$Application$ApplicationEventListener$onStartUp1$InterceptedDefinitionClass', 'co/elastic/apm/agent/impl/transaction/AbstractSpan' }
    stack: { 'java/lang/Throwable' }
    0x0000000: 014c b200 b3c6 0044 b200 b3b6 00b9 4d2c
    0x0000010: c700 21b2 00b3 1202 b600 bdb6 00c1 4c2b
    0x0000020: c600 292b 1301 06b6 00c7 b600 ca57 a700
    0x0000030: 1b2c b600 ce99 0014 2cb6 00d2 1301 06b6
    0x0000040: 00d5 c000 d4b6 00d6 4ca7 0006 b600 d92a
    0x0000050: 4d2c b200 564c 572b a700 034d 014e a700
    0x0000060: 064e 014d 2bc6 0048 2b2d b600 df57 2bb6
    0x0000070: 00e3 b600 e9b6 00ef 3704 2bc1 00d4 9900
    0x0000080: 2616 042b b600 f265 3706 b200 f609 949e
    0x0000090: 0015 1606 b200 f694 9c00 0c2d c700 082b
    0x00000a0: b600 f957 2bb6 00fc 1604 b601 00a7 0006
    0x00000b0: b600 d92d c600 052d bf2c b0
  Exception Handler Table:
    bci [2, 76] => handler: 76
    bci [81, 91] => handler: 97
    bci [100, 176] => handler: 176
  Stackmap Table:


... further down:

2020-06-30 18:27:21.413 [elastic-apm-init-instrumentation-shutdown-hook] INFO co.elastic.apm.agent.report.ApmServerReporter - dropped events because of full queue: 0
2020-06-30 18:27:21.457 [elastic-apm-init-instrumentation-shutdown-hook] INFO co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Reported events: 5
2020-06-30 18:27:21.457 [elastic-apm-init-instrumentation-shutdown-hook] INFO co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Dropped events: 0
2020-06-30 18:27:21.458 [elastic-apm-circuit-breaker] INFO co.elastic.apm.agent.impl.circuitbreaker.CircuitBreaker - Stopping the Circuit Breaker thread.

Not a known issue, but sounds like a bytecode instrumentation error. Could be our agent exposing such in a class generated by Micronaut.

As a workaround, try excluding problematic classes from instrumentation using the classes_excluded_from_instrumentation config, for example:


Also, would be interesting to see what happens with different Java version.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.