quarkusio/quarkus · error · RuntimeException

Could not read class path resources having path

Error message

Could not read class path resources having path '${resourcePath}'

What it means

When reading the service descriptor resource from the classpath fails with an IOException, allProvidersFromClassPath wraps it in a RuntimeException identifying the resource path that could not be read. It signals the descriptor file for the SPI is missing or unreadable at build time.

Solutions

  1. Add the artifact containing the META-INF/services descriptor to the extension/app dependencies
  2. Verify the interface name matches the real FQCN (resource path is META-INF/services/<FQCN>)
  3. If zero providers is acceptable, guard the call or check resource existence first

Example fix

// before
ServiceProviderBuildItem.allProvidersFromClassPath("com.example.WrongSpiName");
// after
// use exact FQCN and ensure provider jar is a dependency
ServiceProviderBuildItem.allProvidersFromClassPath("com.example.CorrectSpi");
Defensive patterns

Strategy: fallback

Validate before calling

URL r = Thread.currentThread().getContextClassLoader().getResource("META-INF/services/" + ifaceName);
if (r == null) { /* descriptor absent — skip or add dependency */ }

Try / catch

try { item = ServiceProviderBuildItem.allProvidersFromClassPath(iface); } catch (RuntimeException e) { log.error("Missing/unreadable SPI descriptor for " + iface, e); throw e; }

Prevention

When it happens

Trigger: Calling allProvidersFromClassPath(iface) when no META-INF/services/<iface> file exists on the context classloader, or the resource cannot be opened.

Common situations: The provider JAR (containing the descriptor) is not on the deployment classpath; typo in the fully-qualified interface name so the resource path doesn't match; dependency excluded in the build.

Related errors


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

Appendix: source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java:92

     * @param serviceInterfaceClassName the interface whose service interface descriptor file we want to embed
     * @return a new {@link ServiceProviderBuildItem}
     * @throws RuntimeException wrapping any {@link IOException}s thrown when accessing class path resources
     */
    public static ServiceProviderBuildItem allProvidersFromClassPath(final String serviceInterfaceClassName) {
        if (serviceInterfaceClassName == null || serviceInterfaceClassName.trim().isEmpty()) {
            throw new IllegalArgumentException("service interface name cannot be null or blank");
        }
        final String resourcePath = SPI_ROOT + serviceInterfaceClassName;
        try {
            Set<String> implementations = ServiceUtil.classNamesNamedIn(
                    Thread.currentThread().getContextClassLoader(),
                    resourcePath);
            return new ServiceProviderBuildItem(
                    serviceInterfaceClassName,
                    List.copyOf(implementations),
                    false);
        } catch (IOException e) {
            throw new RuntimeException("Could not read class path resources having path '" + resourcePath + "'", e);
        }
    }

    /**
     * Creates a new {@link Collection} of {@code ServiceProviderBuildItem}s for the selected artifact.
     * It includes all the providers, that are contained in all the service interface descriptor files defined in
     * {@code "META-INF/services/"} in the selected artifact.
     *
     * @param dependencies the resolved dependencies of the build
     * @param artifactCoordinates the coordinates of the artifact containing the service definitions
     * @return a {@link Collection} of {@code ServiceProviderBuildItem}s containing all the found service providers
     */
    public static Collection<ServiceProviderBuildItem> allProvidersOfDependency(
            Collection<ResolvedDependency> dependencies,
            ArtifactCoords artifactCoordinates) {

        return allProvidersOfDependencies(dependencies, List.of(artifactCoordinates));
    }

View on GitHub (pinned to e1c734241f)