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

  1. Filter null/blank entries before constructing: providers.stream().filter(s -> s != null && !s.isBlank())
  2. Use ServiceProviderBuildItem.allProviders/allProvidersFromClassPath which parse cleanly
  3. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/542e50dd18c412a1. Report an issue: GitHub.