apache/pulsar · critical · PulsarClientException
pulsarServiceUrl cannot be null
Error message
pulsarServiceUrl cannot be null
What it means
createPulsarClientBuilder builds a PulsarClient.Builder from a service URL, auth config, and optional memory limit. If the pulsarServiceUrl argument is null it cannot construct a client and throws PulsarClientException("pulsarServiceUrl cannot be null") after applying any TLS/auth settings. This is a precondition check for missing instance configuration.
Source
Thrown at pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java:187
.serviceUrl(pulsarServiceUrl);
if (authConfig != null) {
if (isNotBlank(authConfig.getClientAuthenticationPlugin())
&& isNotBlank(authConfig.getClientAuthenticationParameters())) {
clientBuilder.authentication(authConfig.getClientAuthenticationPlugin(),
authConfig.getClientAuthenticationParameters());
}
clientBuilder.enableTls(authConfig.isUseTls());
clientBuilder.allowTlsInsecureConnection(authConfig.isTlsAllowInsecureConnection());
clientBuilder.enableTlsHostnameVerification(authConfig.isTlsHostnameVerificationEnable());
clientBuilder.tlsTrustCertsFilePath(authConfig.getTlsTrustCertsFilePath());
}
if (memoryLimit.isPresent()) {
clientBuilder.memoryLimit(memoryLimit.get(), SizeUnit.BYTES);
}
clientBuilder.ioThreads(Runtime.getRuntime().availableProcessors());
return clientBuilder;
}
throw new PulsarClientException("pulsarServiceUrl cannot be null");
}
public static PulsarClient createPulsarClient(String pulsarServiceUrl, AuthenticationConfig authConfig)
throws PulsarClientException {
return createPulsarClient(pulsarServiceUrl, authConfig, Optional.empty());
}
public static PulsarClient createPulsarClient(String pulsarServiceUrl,
AuthenticationConfig authConfig,
Optional<Long> memoryLimit) throws PulsarClientException {
return createPulsarClientBuilder(pulsarServiceUrl, authConfig, memoryLimit).build();
}
public static PulsarAdmin createPulsarAdminClient(String pulsarWebServiceUrl, AuthenticationConfig authConfig)
throws PulsarClientException {
PulsarAdminBuilder pulsarAdminBuilder = null;
if (isNotBlank(pulsarWebServiceUrl)) {
pulsarAdminBuilder = PulsarAdmin.builder().serviceHttpUrl(pulsarWebServiceUrl);View on GitHub (pinned to 820761864e)
Solutions
- Ensure the function instance is launched with a valid pulsarServiceUrl (e.g. pulsar://broker:6650) in the instance config/arguments.
- If building InstanceConfig programmatically, set pulsarServiceUrl before calling createPulsarClient.
- Check the worker's brokerClientConfiguration/serviceUrl settings that feed the per-instance config.
Example fix
// before
InstanceUtils.createPulsarClient(null, authConfig);
// after
InstanceUtils.createPulsarClient("pulsar://localhost:6650", authConfig); Defensive patterns
Strategy: validation
Validate before calling
if (pulsarServiceUrl == null || pulsarServiceUrl.isBlank()) {
throw new IllegalArgumentException("pulsarServiceUrl must be set (e.g. pulsar://broker:6650)");
} Try / catch
try { client = InstanceUtils.createPulsarClient(url, authConfig); } catch (PulsarClientException e) { if (e.getMessage().contains("cannot be null")) { throw new IllegalStateException("Instance config missing pulsarServiceUrl", e); } throw e; } Prevention
- Always launch instances with --pulsarServiceUrl
- Validate InstanceConfig fields before creating clients
- Keep worker brokerClientConfiguration serviceUrl populated
When it happens
Trigger: createPulsarClient(null, authConfig, ...) is invoked — i.e. the instance config's pulsarServiceUrl was null, commonly when InstanceConfig was built without a service URL or it was not injected into the function environment.
Common situations: Missing `--pulsarServiceUrl` argument in the function instance launcher; incorrect KubernetesRuntime/ProcessRuntime config templates; hand-rolled InstanceConfig in tests omitting the service URL.
Related errors
- Getting consumer is not supported
- pulsarWebServiceUrl cannot be null
- Function config is not provided
- The shared resource doesn't support thread pool configurati
- No resources have been configured while using shareConfigure
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/df59f8da25bb2665.
Report an issue: GitHub.