open-telemetry / open-telemetry/opentelemetry-java
Can't build OpenTelemetrySdk in groovy
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.5k
- Forks
- 1k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 58
Description
Describe the bug
Using OpenTelemetrySdk.builder().build() throws an exception if called from a groovy class.
Steps to reproduce
Project with two dependencies
implementation("io.opentelemetry:opentelemetry-sdk:1.59.0")
implementation("org.apache.groovy:groovy:4.0.25")
Main function in a groovy class
class Test {
static void main(String[] args) {
OpenTelemetrySdk.builder().build();
}
}
What did you expect to see?
No exception
What did you see instead?
Exception in thread "main" java.lang.NoClassDefFoundError: io/opentelemetry/api/incubator/config/ConfigProvider
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
at org.codehaus.groovy.reflection.ReflectionUtils.doGetMethods(ReflectionUtils.java:153)
at org.codehaus.groovy.reflection.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:143)
at groovy.lang.MetaClassImpl.findMethod(MetaClassImpl.java:1170)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1132)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1007)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
at test.Test.main(Bloop.groovy:8)
Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.config.ConfigProvider
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.config.ConfigProvider
What version and what artifacts are you using?
Artifacts: opentelemetry-sdk
Version: 1.59.0 +
How did you reference these artifacts?
implementation("io.opentelemetry:opentelemetry-sdk:1.59.0")
Environment
Compiler: Javac
OS: Linux
Runtime: Corretto 17
Additional context
Using groovy 5 still errors, but a different error (groovy.lang.MissingMethodException)
Appears to be caused by #7991.
Even though the return of build() here doesn't go down the IncubatingUtil.createExtendedOpenTelemetrySdk code branch groovy appears to try to link the IncubatingUtil class and since the incubator classes are not on the class path it fails.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the two dependencies and the Groovy Test class. Read sdk/all/src/main/java/io/opentelemetry/sdk/OpenTelemetrySdkBuilder.java around line 145 and inspect the IncubatingUtil.createExtendedOpenTelemetrySdk branch and its linkage; done means OpenTelemetrySdk.builder().build() runs from Groovy without the reported class-loading or method error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100