Skip to content

[Native Image] -H:ServiceLoaderFeatureExcludeServices broken by included resources #12768

@sdeleuze

Description

@sdeleuze

Describe the Issue

Spring has to leverage -H:ServiceLoaderFeatureExcludeServices=org.hibernate.bytecode.spi.BytecodeProvider in order to support Hibernate. It works as expected except when users are configured a resource inclusion for META-INF/services/org.hibernate.bytecode.spi.BytecodeProvider that can typically comes from a resource pattern or be generated by the tracing agent as described in spring-projects/spring-framework#35118.

As discussed with @vjovanov, it should not be possible to break -H:ServiceLoaderFeatureExcludeServices with such resource inclusion.

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

openjdk version "25.0.1" 2025-10-21 LTS
OpenJDK Runtime Environment Liberica-NIK-25.0.1-1 (build 25.0.1+12-LTS)
OpenJDK 64-Bit Server VM Liberica-NIK-25.0.1-1 (build 25.0.1+12-LTS, mixed mode, sharing)

Operating System and Version

MacOS

Troubleshooting Confirmation

Run Command

./demo

Expected Behavior

A Spring Boot application using the Spring Data JPA starter should not be broken by adding the native image resource META-INF/services/org.hibernate.bytecode.spi.BytecodeProvider

Actual Behavior

A Spring Boot application using the Spring Data JPA starter is broken by adding the native image resource META-INF/services/org.hibernate.bytecode.spi.BytecodeProvider

Steps to Reproduce

  1. Create a Spring Boot application with https://start.spring.io/#!type=maven-project&language=java&platformVersion=4.0.1&packaging=jar&configurationFileFormat=properties&jvmVersion=25&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=native,data-jpa
  2. Add a reachability metadata with a resource for META-INF/services/org.hibernate.bytecode.spi.BytecodeProvider
  3. ./gradlew nativeCompile

Additional Context

No response

Run-Time Log Output and Error Messages

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions