quarkusio/quarkus · error · IllegalArgumentException

Classpath resource ${path} not found for MicroProfile Rest C

Error message

Classpath resource ${path} not found for MicroProfile Rest Client SSL configuration

What it means

RestClientBase.locateStream() resolves classpath: URLs for keystore/truststore paths. It tries the thread context ClassLoader then the class's own ClassLoader, and throws this IllegalArgumentException when neither can open the resource — the file is not on the application classpath under that exact path.

Source

Thrown at extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java:227

                throw new IllegalArgumentException("Failed to initialize trust store from classpath resource " + trustStorePath,
                        e);
            }

            builder.trustStore(trustStore);
        } catch (KeyStoreException e) {
            throw new IllegalArgumentException("Failed to initialize trust store from " + trustStorePath, e);
        }
    }

    private InputStream locateStream(String path) throws FileNotFoundException {
        if (path.startsWith("classpath:")) {
            path = path.replaceFirst("classpath:", "");
            InputStream resultStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
            if (resultStream == null) {
                resultStream = getClass().getResourceAsStream(path);
            }
            if (resultStream == null) {
                throw new IllegalArgumentException(
                        "Classpath resource " + path + " not found for MicroProfile Rest Client SSL configuration");
            }
            return resultStream;
        } else {
            if (path.startsWith("file:")) {
                path = path.replaceFirst("file:", "");
            }
            File certificateFile = new File(path);
            if (!certificateFile.isFile()) {
                throw new IllegalArgumentException(
                        "Certificate file: " + path + " not found for MicroProfile Rest Client SSL configuration");
            }
            return new FileInputStream(certificateFile);
        }
    }

    protected void configureProviders(RestClientBuilder builder) {
        Optional<String> providers = oneOf(restClientConfig.providers(), configRoot.providers());

View on GitHub (pinned to e1c734241f)

Solutions

  1. Move the file into src/main/resources at the exact path referenced
  2. Align the path spelling: classpath:certs/truststore.jks, matching the actual resource location and slash usage
  3. Verify at runtime with getClass().getResourceAsStream("/certs/truststore.jks") before startup
  4. Prefer file: paths for stores living outside the artifact (e.g. /etc/certs/) to avoid packaging issues

Example fix

// before (application.properties)
quarkus.rest-client.payment.trust-store=classpath:/certs/truststore.jks
// after — file actually at src/main/resources/certs/truststore.jks
quarkus.rest-client.payment.trust-store=classpath:certs/truststore.jks
Defensive patterns

Strategy: validation

Validate before calling

// fail fast if the classpath resource is absent
String path = "certs/truststore.jks";
if (getClass().getClassLoader().getResourceAsStream(path) == null) {
    throw new IllegalStateException("Missing classpath resource: " + path);
}

Prevention

When it happens

Trigger: quarkus.rest-client.<key>.trust-store or keystore value starts with 'classpath:' but no resource exists at the remaining path in the runtime classloader (e.g. classpath:certs/truststore.jks with no src/main/resources/certs/truststore.jks).

Common situations: File placed in src/test/resources only; leading slash mismatch (classpath:/x vs classpath:x); resource in a different module not declared as a dependency; packaged inside a jar but excluded by packaging config.

Understand the failure class

Related errors


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