When following the documentation on enabling OpenID Connect authentication in the Function Worker, you are presented with the following error.
[jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd] error Uncaught exception in thread main: Cannot construct instance of `java.util.HashSet` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID')
I'm not sure what value if any I've configured incorrectly to cause this, here is an example of my configuration in the functions_worker.yml file.
authenticationEnabled: true
authenticationProviders: "org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID"
properties:
openIDAllowedTokenIssuers: "https://stg.some-website.com/"
openIDAllowedAudiences: "https://some-website.com/maas, https://some-website.com/userinfo"
openIDRoleClaim: "https://some-web.com/role"
openIDAcceptedTimeLeewaySeconds: 0
openIDCacheSize: 5
openIDCacheRefreshAfterWriteSeconds: 64800
openIDCacheExpirationSeconds: 86400
openIDHttpConnectionTimeoutMillis: 10000
openIDHttpReadTimeoutMillis: 10000
openIDRequireIssuersUseHttps: true
openIDFallbackDiscoveryMode: "DISABLED"
Here is the full stack trace
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: 2023-07-06T22:47:15,473Z [jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd] error Uncaught exception in thread main: Cannot construct instance of `java.util.HashSet` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID')
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at [Source: (File); line: 306, column: 26] (through reference chain: org.apache.pulsar.functions.worker.WorkerConfig["authenticationProviders"])
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.HashSet` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID')
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at [Source: (File); line: 306, column: 26] (through reference chain: org.apache.pulsar.functions.worker.WorkerConfig["authenticationProviders"])
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1728)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1353)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromString(StdDeserializer.java:311)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.handleNonArray(StringCollectionDeserializer.java:284)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:192)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:182)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:25)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3494)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at org.apache.pulsar.functions.worker.WorkerConfig.load(WorkerConfig.java:776)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at org.apache.pulsar.broker.PulsarService.initializeWorkerConfigFromBrokerConfig(PulsarService.java:1840)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at org.apache.pulsar.PulsarBrokerStarter$BrokerStarter.<init>(PulsarBrokerStarter.java:194)
Jul 06 22:47:15 lin-0afa7c99.mstarext.com pulsar[6665]: at org.apache.pulsar.PulsarBrokerStarter.main(PulsarBrokerStarter.java:333)
The authenticationProviders
parameter must be passed as a yaml list. Here is the correct input:
authenticationProviders: ["org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID"]
You can also input it this way:
authenticationProviders:
- "org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID"
Note that the error indicates this when it says:
Cannot construct instance of
java.util.HashSet
It is trying to create a set from the value of authenticationProviders
.
Note: the docs were originally incorrect. I updated them here: https://github.com/apache/pulsar-site/pull/632.