{"record":{"id":"35a4bf26184370ee","repo":"prestodb/presto","slug":"error-creating-an-instance-of-s-for-uri-s","errorCode":null,"errorMessage":"Error creating an instance of %s for URI %s","messagePattern":"Error creating an instance of (.+?) for URI (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java","lineNumber":893,"sourceCode":"        String providerClass = conf.get(S3_CREDENTIALS_PROVIDER);\n        if (!isNullOrEmpty(providerClass)) {\n            return getCustomAWSCredentialsProvider(uri, conf, providerClass);\n        }\n\n        return DefaultAWSCredentialsProviderChain.getInstance();\n    }\n\n    private static AWSCredentialsProvider getCustomAWSCredentialsProvider(URI uri, Configuration conf, String providerClass)\n    {\n        try {\n            log.debug(\"Using AWS credential provider %s for URI %s\", providerClass, uri);\n            return conf.getClassByName(providerClass)\n                    .asSubclass(AWSCredentialsProvider.class)\n                    .getConstructor(URI.class, Configuration.class)\n                    .newInstance(uri, conf);\n        }\n        catch (ReflectiveOperationException e) {\n            throw new RuntimeException(format(\"Error creating an instance of %s for URI %s\", providerClass, uri), e);\n        }\n    }\n\n    private static Optional<AWSCredentials> getAwsCredentials(URI uri, Configuration conf)\n    {\n        String accessKey = conf.get(S3_ACCESS_KEY);\n        String secretKey = conf.get(S3_SECRET_KEY);\n\n        String userInfo = uri.getUserInfo();\n        if (userInfo != null) {\n            int index = userInfo.indexOf(':');\n            if (index < 0) {\n                accessKey = userInfo;\n            }\n            else {\n                accessKey = userInfo.substring(0, index);\n                secretKey = userInfo.substring(index + 1);\n            }","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java#L875-L911","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Implement the constructor with signature (URI, Configuration) in the provider class.","Verify the class is on the plugin classpath and restart Presto.","Fix the underlying exception in the constructor (see the cause chain in logs).","Correct the fully-qualified class name in s3.aws-credentials-provider config."],"exampleFix":"// before\npublic class MyProvider implements AWSCredentialsProvider {\n    public MyProvider() { ... }\n}\n// after\npublic class MyProvider implements AWSCredentialsProvider {\n    public MyProvider(URI uri, Configuration conf) { ... }\n}","handlingStrategy":"try-catch","validationCode":"String cls = conf.get(\"hive.s3.aws-credentials-provider\");\nif (cls != null) {\n    Class<?> c = Class.forName(cls);\n    if (!AWSCredentialsProvider.class.isAssignableFrom(c)) {\n        throw new IllegalStateException(cls + \" is not an AWSCredentialsProvider\");\n    }\n    c.getConstructor(URI.class, org.apache.hadoop.conf.Configuration.class); // required signature\n}","typeGuard":"boolean hasRequiredCtor(Class<?> c) {\n    try { c.getConstructor(URI.class, org.apache.hadoop.conf.Configuration.class); return true; }\n    catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n    createAwsCredentialsProvider(uri, conf);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Error creating an instance of\")) {\n        LOG.error(\"provider {} for {} failed; check constructor signature and classpath\", e);\n    }\n    throw e;\n}","preventionTips":["Always implement the (URI, Configuration) constructor in custom providers.","Keep provider jars on the plugin classpath.","Keep the provider constructor side-effect-free and fail-fast with clear messages.","Match AWS SDK versions used to compile the provider with the server's."],"tags":["s3","credentials","reflection","configuration"],"backgroundTag":"invalid-configuration-class","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"}