{"record":{"id":"944e64a1e06d3c3b","repo":"quarkusio/quarkus","slug":"could-not-read-class-path-resources-having-path","errorCode":null,"errorMessage":"Could not read class path resources having path '${resourcePath}'","messagePattern":"Could not read class path resources having path '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java","lineNumber":92,"sourceCode":"     * @param serviceInterfaceClassName the interface whose service interface descriptor file we want to embed\n     * @return a new {@link ServiceProviderBuildItem}\n     * @throws RuntimeException wrapping any {@link IOException}s thrown when accessing class path resources\n     */\n    public static ServiceProviderBuildItem allProvidersFromClassPath(final String serviceInterfaceClassName) {\n        if (serviceInterfaceClassName == null || serviceInterfaceClassName.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"service interface name cannot be null or blank\");\n        }\n        final String resourcePath = SPI_ROOT + serviceInterfaceClassName;\n        try {\n            Set<String> implementations = ServiceUtil.classNamesNamedIn(\n                    Thread.currentThread().getContextClassLoader(),\n                    resourcePath);\n            return new ServiceProviderBuildItem(\n                    serviceInterfaceClassName,\n                    List.copyOf(implementations),\n                    false);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Could not read class path resources having path '\" + resourcePath + \"'\", e);\n        }\n    }\n\n    /**\n     * Creates a new {@link Collection} of {@code ServiceProviderBuildItem}s for the selected artifact.\n     * It includes all the providers, that are contained in all the service interface descriptor files defined in\n     * {@code \"META-INF/services/\"} in the selected artifact.\n     *\n     * @param dependencies the resolved dependencies of the build\n     * @param artifactCoordinates the coordinates of the artifact containing the service definitions\n     * @return a {@link Collection} of {@code ServiceProviderBuildItem}s containing all the found service providers\n     */\n    public static Collection<ServiceProviderBuildItem> allProvidersOfDependency(\n            Collection<ResolvedDependency> dependencies,\n            ArtifactCoords artifactCoordinates) {\n\n        return allProvidersOfDependencies(dependencies, List.of(artifactCoordinates));\n    }","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ServiceProviderBuildItem.java#L74-L110","documentation":"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.","triggerScenarios":"Calling allProvidersFromClassPath(iface) when no META-INF/services/<iface> file exists on the context classloader, or the resource cannot be opened.","commonSituations":"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.","solutions":["Add the artifact containing the META-INF/services descriptor to the extension/app dependencies","Verify the interface name matches the real FQCN (resource path is META-INF/services/<FQCN>)","If zero providers is acceptable, guard the call or check resource existence first"],"exampleFix":"// before\nServiceProviderBuildItem.allProvidersFromClassPath(\"com.example.WrongSpiName\");\n// after\n// use exact FQCN and ensure provider jar is a dependency\nServiceProviderBuildItem.allProvidersFromClassPath(\"com.example.CorrectSpi\");","handlingStrategy":"fallback","validationCode":"URL r = Thread.currentThread().getContextClassLoader().getResource(\"META-INF/services/\" + ifaceName);\nif (r == null) { /* descriptor absent — skip or add dependency */ }","typeGuard":null,"tryCatchPattern":"try { item = ServiceProviderBuildItem.allProvidersFromClassPath(iface); } catch (RuntimeException e) { log.error(\"Missing/unreadable SPI descriptor for \" + iface, e); throw e; }","preventionTips":["Ensure the artifact containing META-INF/services/<FQCN> is on the deployment classpath","Verify the interface FQCN spelling exactly matches the descriptor path","Check dependency exclusions didn't remove the provider JAR"],"tags":["native-image","spi","classpath","io"],"backgroundTag":"classpath-resource-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}