Skip to content

Unable to load SPI in springboot #10921

@crossoverJie

Description

@crossoverJie

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

java  -javaagent:opentelemetry-javaagent.jar \
      -jar target/demo-0.0.1-SNAPSHOT.jar

image

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

java -jar  target/demo-0.0.1-SNAPSHOT.jar

It's work fine.

image

And the classloader is correct: URLClassPath$Loader@1211

When I use this command (with javaagent):

java  -javaagent:opentelemetry-javaagent.jar \
      -jar target/demo-0.0.1-SNAPSHOT.jar

image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions