{"record":{"id":"104956336090e397","repo":"apache/pulsar","slug":"failed-to-create-authentication-message","errorCode":null,"errorMessage":"Failed to create authentication: ${message}","messagePattern":"Failed to create authentication: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminBuilderImpl.java","lineNumber":257,"sourceCode":"        conf.setAuthentication(AuthenticationFactory.create(authPluginClassName, authParamsString));\n        return this;\n    }\n\n    private void setAuthenticationFromPropsIfAvailable(ClientConfigurationData clientConfig) {\n        String authPluginClass = clientConfig.getAuthPluginClassName();\n        String authParams = clientConfig.getAuthParams();\n        Map<String, String> authParamMap = clientConfig.getAuthParamMap();\n        if (StringUtils.isBlank(authPluginClass) || (StringUtils.isBlank(authParams) && authParamMap == null)) {\n            return;\n        }\n        try {\n            if (StringUtils.isNotBlank(authParams)) {\n                authentication(authPluginClass, authParams);\n            } else if (authParamMap != null) {\n                authentication(authPluginClass, authParamMap);\n            }\n        } catch (UnsupportedAuthenticationException ex) {\n            throw new RuntimeException(\"Failed to create authentication: \" + ex.getMessage(), ex);\n        }\n    }\n\n    @Override\n    public PulsarAdminBuilder tlsKeyFilePath(String tlsKeyFilePath) {\n        conf.setTlsKeyFilePath(tlsKeyFilePath);\n        return this;\n    }\n\n    @Override\n    public PulsarAdminBuilder tlsCertificateFilePath(String tlsCertificateFilePath) {\n        conf.setTlsCertificateFilePath(tlsCertificateFilePath);\n        return this;\n    }\n\n    @Override\n    public PulsarAdminBuilder tlsTrustCertsFilePath(String tlsTrustCertsFilePath) {\n        conf.setTlsTrustCertsFilePath(tlsTrustCertsFilePath);","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PulsarAdminBuilderImpl.java#L239-L275","documentation":"RuntimeException thrown by loadConf-driven authentication setup when the configured authentication plugin class cannot be instantiated or configured (UnsupportedAuthenticationException). loadConf applies configuration properties including authPluginClass/authParams; if the plugin class is unknown, not on the classpath, or rejects the parameters, the builder fails eagerly with this message.","triggerScenarios":"PulsarAdminBuilder.loadConf(props) where the properties include authPluginClass pointing to a class that doesn't exist, doesn't implement Authentication, or whose init() throws UnsupportedAuthenticationException for the supplied authParams.","commonSituations":"Typo in the fully-qualified plugin class name; auth plugin jar missing from the classpath; migrating from AuthenticationTls to OAuth2 (or vice versa) with stale properties files; passing JSON authParams the plugin can't parse.","solutions":["Verify the authPluginClass value matches an available Authentication implementation on the classpath.","Validate authParams against the plugin's expected format (e.g. OAuth2 JSON with issuerUrl, clientId, clientCredential).","Add the auth plugin dependency/jar to the application classpath.","Call .authentication(pluginClass, params) directly in a controlled place to get the underlying UnsupportedAuthenticationException with its real message."],"exampleFix":"// before\nprops.put(\"authPluginClass\", \"com.example.MissingAuthPlugin\");\nbuilder.loadConf(props);\n// after\nprops.put(\"authPluginClass\", \"org.apache.pulsar.client.impl.auth.AuthenticationToken\");\nprops.put(\"authParams\", \"file:///etc/pulsar/token.txt\");\nbuilder.loadConf(props);","handlingStrategy":"validation","validationCode":"String plugin = props.getProperty(\"authPluginClass\");\nif (plugin != null) {\n    try {\n        Class<?> c = Class.forName(plugin);\n        if (!Authentication.class.isAssignableFrom(c))\n            throw new IllegalArgumentException(plugin + \" is not an Authentication\");\n    } catch (ClassNotFoundException e) {\n        throw new IllegalArgumentException(\"auth plugin not on classpath: \" + plugin);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    builder.loadConf(props);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Failed to create authentication\")) {\n        log.error(\"bad auth config: {}\", e.getCause(), e);\n    }\n    throw e;\n}","preventionTips":["Keep auth plugin class names in a constants file, never inline strings","Ship the auth plugin jar with your application","Validate properties files after upgrades — plugin names and params change between versions","Test the same auth config with PulsarClient before wiring it into the admin"],"tags":["authentication","configuration","reflection"],"backgroundTag":"auth-plugin-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}