-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to load SPI in springboot #10921
Comments
Do I understand correctly that the issue is that because agent tries to establish network connections it will trigger loading |
Thank you for your reply. Could you please explain in detail how to achieve this? |
No, I can't, I'm not a spring boot user and don't know exactly how you'd do this. Spring boot questions are best asked from spring boot channels or stack overflow. In your place I'd start by manually modifying the jar and seeing whether it resolves the issue. If it helps I'd check the documentation for spring boot plugin for the build system in use, for example https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#packaging.layers.configuration looks promising. |
Hi @laurit @crossoverJie, As @laurit mentioned, system-wide When I have debug the code, I have seen that As a workaround, you can disable
|
@serkan-ozal Thank you for your reply.
I have added this system property, but it's not work for me. I have created a demo repo; if you have time, you can give it a try. |
@crossoverJie Sorry, it is my bad. I made an error while copy-pasting full classname of the For the correct workaround, you can disable
OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS=io.opentelemetry.instrumentation.resources.HostResourceProvider
-Dotel.java.disabled.resource-providers=io.opentelemetry.instrumentation.resources.HostResourceProvider I have tried with your example and verified that it works. |
@serkan-ozal Thank you for your help. It works for me. I found Is there any other better solution? |
Seems like the loading of |
Hi @laurit I think the easiest fix for this issue might be resetting (setting to I have tried this solution and verified that it works. However, since we use reflection to set the private JavaModule currentModule = JavaModule.ofType(JavaNetInitializer.class);
JavaModule javaBase = JavaModule.ofType(ClassLoader.class);
if (javaBase != null && javaBase.isNamed() && currentModule != null) {
ClassInjector.UsingInstrumentation.redefineModule(
instrumentation,
javaBase,
Collections.emptySet(),
Collections.emptyMap(),
Collections.singletonMap("java.net", Collections.singleton(currentModule)),
Collections.emptySet(),
Collections.emptyMap());
} So, if that makes sense for you, I can send a PR for further discussions. |
Describe the bug
When using
java.net.spi.InetAddressResolverProvider
, the custom SPI does not load properly.Steps to reproduce
META-INF/services/java.net.spi.InetAddressResolverProvider:
com.example.demo.MyAddressResolverProvider
Expected behavior
Customized implementation takes effect successfully.
Actual behavior
Custom implementation does not take effect.
Javaagent or library instrumentation version
1.32.0
Environment
JDK:21
OS: Linux/MacOS
Additional context
When I use this command (without a javaagent):
It's work fine.
And the classloader is correct:
URLClassPath$Loader@1211
When I use this command (with javaagent):
The classloader is incorrect:
URLClassPath$JarLoader@814
. The JarLoader cannot load the springboot jar; it can only load the normal Maven project jar.And this method cannot be called
org.springframework.boot.loader.launch.JarLauncher#main
.If I don't use Spring Boot instead of a normal Maven project, it'll also work fine.
The text was updated successfully, but these errors were encountered: