{"record":{"id":"35779e46ff526f69","repo":"prestodb/presto","slug":"error-creating-an-instance-of-s","errorCode":null,"errorMessage":"Error creating an instance of %s","messagePattern":"Error creating an instance of (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3ClientFactory.java","lineNumber":163,"sourceCode":"\n        String providerClass = conf.get(S3_CREDENTIALS_PROVIDER);\n        if (!isNullOrEmpty(providerClass)) {\n            return getCustomAWSCredentialsProvider(conf, providerClass);\n        }\n\n        return DefaultAWSCredentialsProviderChain.getInstance();\n    }\n\n    private static AWSCredentialsProvider getCustomAWSCredentialsProvider(Configuration conf, String providerClass)\n    {\n        try {\n            return conf.getClassByName(providerClass)\n                    .asSubclass(AWSCredentialsProvider.class)\n                    .getConstructor(URI.class, Configuration.class)\n                    .newInstance(null, conf);\n        }\n        catch (ReflectiveOperationException e) {\n            throw new RuntimeException(format(\"Error creating an instance of %s\", providerClass), e);\n        }\n    }\n\n    private static Optional<AWSCredentials> getAwsCredentials(Configuration conf)\n    {\n        String accessKey = conf.get(S3_ACCESS_KEY);\n        String secretKey = conf.get(S3_SECRET_KEY);\n\n        if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) {\n            return Optional.empty();\n        }\n        return Optional.of(new BasicAWSCredentials(accessKey, secretKey));\n    }\n}\n","sourceCodeStart":145,"sourceCodeEnd":178,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3ClientFactory.java#L145-L178","documentation":"PrestoS3ClientFactory.getCustomAWSCredentialsProvider instantiates a user-configured AWSCredentialsProvider class reflectively (constructor taking (URI, Configuration)) via conf.getClassByName(...).getConstructor(...).newInstance(...). Any ReflectiveOperationException (class missing, no matching constructor, constructor threw) is rethrown as RuntimeException 'Error creating an instance of %s'.","triggerScenarios":"hive.s3.credentials-provider is set to a class that: doesn't exist on the classpath (ClassNotFoundException), lacks a (URI, Configuration) constructor (NoSuchMethodException), isn't an AWSCredentialsProvider subclass, or whose constructor throws (InvocationTargetException) — e.g., reading a missing credentials file in its constructor.","commonSituations":"Typo in the fully-qualified class name; custom provider jar not deployed to the hive plugin directory on all nodes; provider written against a different SDK version where the constructor signature changed; provider fails at runtime because it depends on env vars/files absent on workers.","solutions":["Check the wrapped cause in the message: ClassNotFoundException -> deploy the jar; NoSuchMethodException -> add a (URI, Configuration) constructor; InvocationTargetException -> fix the provider's constructor.","Implement the provider as public class X implements AWSCredentialsProvider with a public constructor (URI, Configuration).","Deploy the provider jar to the hive plugin directory (presto-hive/target or plugin/hive-hadoop2/...) on EVERY node and restart.","Verify the class name matches hive.s3.credentials-provider exactly (package + class, case-sensitive)."],"exampleFix":"// before: no (URI, Configuration) constructor\npublic class MyProvider implements AWSCredentialsProvider {\n    public MyProvider() { ... }\n}\n// after\npublic class MyProvider implements AWSCredentialsProvider {\n    public MyProvider(URI uri, Configuration conf) { ... }\n    @Override public AWSCredentials getCredentials() { ... }\n    @Override public void refresh() { ... }\n}","handlingStrategy":"validation","validationCode":"// pre-check the configured credentials provider before wiring it into the catalog\nClass<?> cls = Class.forName(conf.get(\"hive.s3.credentials-provider\"));\nif (!AWSCredentialsProvider.class.isAssignableFrom(cls)) throw new IllegalStateException(\"Not an AWSCredentialsProvider\");\ncls.getConstructor(URI.class, Configuration.class); // throws NoSuchMethodException if signature missing","typeGuard":"boolean isValidCredentialsProvider(String className, ClassLoader cl) {\n    try {\n        Class<?> c = Class.forName(className, false, cl);\n        return AWSCredentialsProvider.class.isAssignableFrom(c)\n            && c.getConstructor(URI.class, Configuration.class) != null;\n    } catch (ReflectiveOperationException e) { return false; }\n}","tryCatchPattern":"try {\n    AWSCredentialsProvider p = buildProvider(providerClass, uri, conf);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Error creating an instance of \")) {\n        Throwable cause = e.getCause();\n        // ClassNotFoundException: deploy jar; NoSuchMethodException: fix constructor; InvocationTargetException: fix ctor internals\n        throw new ProviderInitException(\"Fix provider \" + providerClass + \" (cause: \" + cause + \")\");\n    }\n    throw e;\n}","preventionTips":["Implement providers with the exact public (URI, Configuration) constructor.","Deploy the provider jar to plugin/hive-hadoop2/ on every node and restart after upgrades.","Keep the provider compiled against the AWS SDK version bundled with Presto.","Smoke-test the provider in a unit test before wiring it into production config."],"tags":["s3","aws-credentials","reflection","configuration"],"backgroundTag":"credentials-provider-instantiation-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}