I would like to build a native image with the newly released (as of this writing) Spring Boot 4.0.0-M1 and GraalVM AOT
With this code:
@Configuration public class TracingConfiguration { @Bean public SpanExporter otlpGrpcSpanExporter() { return OtlpGrpcSpanExporter.builder().setEndpoint("https://otlp-gateway-prod-us-central-0.grafana.net/otlp/v1/traces").addHeader("Authorization", "Basic ODY2MTg0OaWRYTWlmWDA9").build(); //this is fake } } <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-kafka</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-opentelemetry</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-webclient</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-core-micrometer</artifactId> </dependency> <dependency> <groupId>io.opentelemetry</groupId> <artifactId>opentelemetry-exporter-otlp</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-tracing-bridge-otel</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-otlp</artifactId> </dependency> <dependency> <groupId>io.projectreactor.kafka</groupId> <artifactId>reactor-kafka</artifactId> <version>1.3.23</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-function-context</artifactId> <version>4.3.0</version> </dependency> <dependency> <groupId>com.github.loki4j</groupId> <artifactId>loki-logback-appender</artifactId> <version>2.0.0</version> </dependency> <!-- <dependency>--> <!-- <groupId>io.opentelemetry</groupId>--> <!-- <artifactId>opentelemetry-exporter-sender-okhttp</artifactId>--> <!-- <version>1.52.0</version>--> <!-- </dependency>--> </dependencies> mvn -U -Pnative spring-boot:build-image -DskipTests I get this error message:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSender at io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSenderProvider.createSender(OkHttpGrpcSenderProvider.java:23) at io.opentelemetry.exporter.internal.grpc.GrpcExporterBuilder.build(GrpcExporterBuilder.java:236) at io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder.build(OtlpGrpcSpanExporterBuilder.java:310) at org.example.TracingConfiguration.otlpGrpcSpanExporter(TracingConfiguration.java:25) With version 3.5.3, this would compile fine and run fine. With version 4.0.0-M1, it will always yield java.lang.NoClassDefFoundError: Could not initialize class io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSender
I understand Spring Boot has been modularized for 4.0, which is a great thing.
Which module contains this?
How to fix this issue so the native image can be built?