quarkusio/quarkus · error · IllegalArgumentException
The provider class name cannot be null or blank
Error message
The provider class name cannot be null or blank
What it means
The constructor also validates every entry of the providers list: any null or empty provider class name triggers this IllegalArgumentException, ensuring the generated native-image service registration contains only valid class names.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java:193
* An internal overload that must be called with an immutable {@link List} of {@code providers}
*
* @param serviceInterfaceClassName the interface whose service interface descriptor file we want to embed
* @param providers the list of provider class names that must already be mentioned in the file
* @param marker just a way to differentiate this constructor from {@link #ServiceProviderBuildItem(String, List)};
* the value is ignored
*/
private ServiceProviderBuildItem(String serviceInterfaceClassName, List<String> providers, boolean marker) {
this.serviceInterface = Objects.requireNonNull(serviceInterfaceClassName, "The service interface must not be `null`");
this.providers = providers;
// Validation
if (serviceInterface.isEmpty()) {
throw new IllegalArgumentException("The serviceDescriptorFile interface cannot be blank");
}
providers.forEach(s -> {
if (s == null || s.isEmpty()) {
throw new IllegalArgumentException("The provider class name cannot be null or blank");
}
});
}
/**
* @return an immutable {@link List} of provider class names
*/
public List<String> providers() {
return providers;
}
/**
* @return the resource path for the service descriptor file
*/
public String serviceDescriptorFile() {
return SPI_ROOT + serviceInterface;
}
}View on GitHub (pinned to e1c734241f)
Solutions
- Filter null/blank entries before constructing: providers.stream().filter(s -> s != null && !s.isBlank())
- Use ServiceProviderBuildItem.allProviders/allProvidersFromClassPath which parse cleanly
- Fix the source (config or file parsing) producing empty names
Example fix
// before new ServiceProviderBuildItem(spi, rawProviders); // after List<String> clean = rawProviders.stream().filter(Objects::nonNull).filter(s -> !s.isBlank()).toList(); new ServiceProviderBuildItem(spi, clean);
Defensive patterns
Strategy: validation
Validate before calling
List<String> clean = providers.stream().filter(Objects::nonNull).filter(s -> !s.isEmpty()).toList();
if (clean.isEmpty()) throw new IllegalStateException("no providers"); Type guard
boolean hasValidProviders(List<String> l) { return l != null && l.stream().allMatch(s -> s != null && !s.isEmpty()); } Prevention
- Filter blank lines when parsing descriptor files
- Reject empty config entries before building the list
- Prefer allProviders()/allProvidersFromClassPath() over manual construction
When it happens
Trigger: Creating a ServiceProviderBuildItem whose providers List contains null or "" elements, e.g. from parsing descriptor lines without filtering empties.
Common situations: Splitting a descriptor file on newlines and passing blank trailing lines; collecting class names from config that has empty entries.
Related errors
- service interface name cannot be null or blank
- The serviceDescriptorFile interface cannot be blank
- service interface descriptor file path cannot be null
- Could not read class path resources having path '${resourceP
- Extra steps left over
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/542e50dd18c412a1.
Report an issue: GitHub.