From 275a9e4d24ac9877bbd3f6f81ea5a785a23ad8b9 Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Thu, 13 Mar 2025 15:47:16 +0100 Subject: [PATCH] Re-add test runtime hints --- .../spring/smoketest/RuntimeHints.java | 13 +++++++++++++ .../spring/smoketest/RuntimeHints.java | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/smoke-tests-otel-starter/spring-boot-3.2/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java b/smoke-tests-otel-starter/spring-boot-3.2/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java index b50d2ca4b244..ab181ee823d5 100644 --- a/smoke-tests-otel-starter/spring-boot-3.2/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java +++ b/smoke-tests-otel-starter/spring-boot-3.2/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java @@ -5,7 +5,9 @@ package io.opentelemetry.spring.smoketest; +import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.aot.hint.TypeReference; // Necessary for GraalVM native test public class RuntimeHints implements RuntimeHintsRegistrar { @@ -14,5 +16,16 @@ public class RuntimeHints implements RuntimeHintsRegistrar { public void registerHints( org.springframework.aot.hint.RuntimeHints hints, ClassLoader classLoader) { hints.resources().registerResourceBundle("org.apache.commons.dbcp2.LocalStrings"); + + // To avoid Spring native issue with MongoDB: java.lang.ClassNotFoundException: + // org.springframework.data.mongodb.core.aggregation.AggregationOperation + hints + .reflection() + .registerType( + TypeReference.of( + "org.springframework.data.mongodb.core.aggregation.AggregationOperation"), + hint -> { + hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); + }); } } diff --git a/smoke-tests-otel-starter/spring-boot-3/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java b/smoke-tests-otel-starter/spring-boot-3/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java index b50d2ca4b244..ab181ee823d5 100644 --- a/smoke-tests-otel-starter/spring-boot-3/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java +++ b/smoke-tests-otel-starter/spring-boot-3/src/main/java/io/opentelemetry/spring/smoketest/RuntimeHints.java @@ -5,7 +5,9 @@ package io.opentelemetry.spring.smoketest; +import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.aot.hint.TypeReference; // Necessary for GraalVM native test public class RuntimeHints implements RuntimeHintsRegistrar { @@ -14,5 +16,16 @@ public class RuntimeHints implements RuntimeHintsRegistrar { public void registerHints( org.springframework.aot.hint.RuntimeHints hints, ClassLoader classLoader) { hints.resources().registerResourceBundle("org.apache.commons.dbcp2.LocalStrings"); + + // To avoid Spring native issue with MongoDB: java.lang.ClassNotFoundException: + // org.springframework.data.mongodb.core.aggregation.AggregationOperation + hints + .reflection() + .registerType( + TypeReference.of( + "org.springframework.data.mongodb.core.aggregation.AggregationOperation"), + hint -> { + hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); + }); } }