diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java index 9bcfd20a9c..ee7ea7cdf2 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java @@ -61,7 +61,11 @@ public final class BytecodeProviderInitiator implements StandardServiceInitiator @Internal public static BytecodeProvider buildDefaultBytecodeProvider() { - return getBytecodeProvider( ServiceLoader.load( BytecodeProvider.class ) ); + // Use BytecodeProvider's ClassLoader to ensure we can find the service + return getBytecodeProvider( ServiceLoader.load( + BytecodeProvider.class, + BytecodeProvider.class.getClassLoader() + ) ); } @Internal