open-telemetry / open-telemetry/opentelemetry-java-instrumentation

NoClassDefFoundError when building native image

Open
#8,919 19 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
2.6k
Forks
1.2k
Avg merge
2d 18h
Merged PRs (30d)
228

Description

Describe the bug
NoClassDefFoundError when building native image

Steps to reproduce

  1. create a simple spring boot3 project
  2. executing this command for build native ./mvnw clean -Pnative native:compile native:build

What did you expect to see?
Should build success

What did you see instead?
causing this exception:

Caused by: java.lang.NoClassDefFoundError: io/opentelemetry/javaagent/tooling/field/VirtualFieldImplementationsGenerator
        at java.base/java.lang.Class.getDeclaringClass0(Native Method)
        at java.base/jdk.internal.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.SVMHost.getDeclaringClass(SVMHost.java:432)

What version are you using?
1.27.0(latest)

Environment
Compiler: (e.g., "GraalVM 17.0.7+8.1")
OS: (e.g., "MacOs")

Contributor guide

Open the contributing guide

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.

Research direction

Start by reproducing the issue with a simple Spring Boot 3 project using ./mvnw clean -Pnative native:compile native:build, then inspect the reported NoClassDefFoundError for VirtualFieldImplementationsGenerator. Done means the native image build completes successfully; the issue does not name a source file or test to modify.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.