prestodb/presto · error · RuntimeException

Error creating an instance of %s for URI %s

Error message

Error creating an instance of %s for URI %s

What it means

The configured AWS credentials provider class is instantiated reflectively via a (URI, Configuration) constructor; any ReflectiveOperationException results in this RuntimeException naming the class and URI. The provider must extend AWSCredentialsProvider and expose that exact constructor.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:893

        String providerClass = conf.get(S3_CREDENTIALS_PROVIDER);
        if (!isNullOrEmpty(providerClass)) {
            return getCustomAWSCredentialsProvider(uri, conf, providerClass);
        }

        return DefaultAWSCredentialsProviderChain.getInstance();
    }

    private static AWSCredentialsProvider getCustomAWSCredentialsProvider(URI uri, Configuration conf, String providerClass)
    {
        try {
            log.debug("Using AWS credential provider %s for URI %s", providerClass, uri);
            return conf.getClassByName(providerClass)
                    .asSubclass(AWSCredentialsProvider.class)
                    .getConstructor(URI.class, Configuration.class)
                    .newInstance(uri, conf);
        }
        catch (ReflectiveOperationException e) {
            throw new RuntimeException(format("Error creating an instance of %s for URI %s", providerClass, uri), e);
        }
    }

    private static Optional<AWSCredentials> getAwsCredentials(URI uri, Configuration conf)
    {
        String accessKey = conf.get(S3_ACCESS_KEY);
        String secretKey = conf.get(S3_SECRET_KEY);

        String userInfo = uri.getUserInfo();
        if (userInfo != null) {
            int index = userInfo.indexOf(':');
            if (index < 0) {
                accessKey = userInfo;
            }
            else {
                accessKey = userInfo.substring(0, index);
                secretKey = userInfo.substring(index + 1);
            }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Implement the constructor with signature (URI, Configuration) in the provider class.
  2. Verify the class is on the plugin classpath and restart Presto.
  3. Fix the underlying exception in the constructor (see the cause chain in logs).
  4. Correct the fully-qualified class name in s3.aws-credentials-provider config.

Example fix

// before
public class MyProvider implements AWSCredentialsProvider {
    public MyProvider() { ... }
}
// after
public class MyProvider implements AWSCredentialsProvider {
    public MyProvider(URI uri, Configuration conf) { ... }
}
Defensive patterns

Strategy: try-catch

Validate before calling

String cls = conf.get("hive.s3.aws-credentials-provider");
if (cls != null) {
    Class<?> c = Class.forName(cls);
    if (!AWSCredentialsProvider.class.isAssignableFrom(c)) {
        throw new IllegalStateException(cls + " is not an AWSCredentialsProvider");
    }
    c.getConstructor(URI.class, org.apache.hadoop.conf.Configuration.class); // required signature
}

Type guard

boolean hasRequiredCtor(Class<?> c) {
    try { c.getConstructor(URI.class, org.apache.hadoop.conf.Configuration.class); return true; }
    catch (NoSuchMethodException e) { return false; }
}

Try / catch

try {
    createAwsCredentialsProvider(uri, conf);
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("Error creating an instance of")) {
        LOG.error("provider {} for {} failed; check constructor signature and classpath", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: hive.s3.aws-credentials-provider (s3.aws-credentials-provider) points to a class missing a (URI, Configuration) constructor, not on the classpath, or whose constructor throws; wrong subclass due to SDK version mismatch.

Common situations: Custom credential provider jar not deployed to plugins; typo in class name; provider written with a no-arg constructor only; provider constructor fails reading missing config/credentials files.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/35a4bf26184370ee. Report an issue: GitHub.