openzipkin/zipkin · error · NullPointerException

serviceUrl is null or empty

Error message

serviceUrl is null or empty

What it means

PulsarCollector.Builder.serviceUrl(String) throws NullPointerException when the service URL is null or empty. The service URL (e.g. pulsar://my-broker:6650) has no default — it is the only mandatory Pulsar setting — so the builder enforces its presence at configuration time, before any network call.

Source

Thrown at zipkin-collector/pulsar/src/main/java/zipkin2/collector/pulsar/PulsarCollector.java:78

    }

    /** Count of concurrent message consumers on the topic. Defaults to 1. */
    public Builder concurrency(Integer concurrency) {
      if (concurrency < 1) throw new IllegalArgumentException("concurrency < 1");
      this.concurrency = concurrency;
      return this;
    }

    /** Queue zipkin spans will be consumed from. Defaults to "zipkin". */
    public Builder topic(String topic) {
      if (StringUtils.isNullOrEmpty(topic)) throw new NullPointerException("topic is null or empty");
      this.topic = topic;
      return this;
    }

    /** The service URL for the Pulsar client ex. pulsar://my-broker:6650. No default. */
    public Builder serviceUrl(String serviceUrl) {
      if (StringUtils.isNullOrEmpty(serviceUrl)) throw new NullPointerException("serviceUrl is null or empty");
      clientProps.put("serviceUrl", serviceUrl);
      return this;
    }

    /** Specify the subscription name for this consumer. No default. */
    public Builder subscriptionName(String subscriptionName) {
      if (StringUtils.isNullOrEmpty(subscriptionName)) throw new NullPointerException("serviceUrl is null or empty");
      consumerProps.put("subscriptionName", subscriptionName);
      return this;
    }

    /**
     * Any properties set here will override the previous Pulsar client configuration.
     *
     * @param clientPropsMap Map<String, Object>
     * @return Builder
     * @see org.apache.pulsar.client.api.ClientBuilder#loadConf(Map)
     */

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Set the service URL explicitly: .serviceUrl("pulsar://my-broker:6650")
  2. Require the env var at startup: Objects.requireNonNull(System.getenv("PULSAR_SERVICE_URL")) before building
  3. Fix the deployment manifest/config template so the value is never blank

Example fix

// before
builder.serviceUrl(System.getenv("PULSAR_SERVICE_URL")); // null when unset

// after
String url = Objects.requireNonNull(
  System.getenv("PULSAR_SERVICE_URL"), "PULSAR_SERVICE_URL must be set");
builder.serviceUrl(url);
Defensive patterns

Strategy: validation

Validate before calling

String url = Objects.requireNonNull(System.getenv("PULSAR_SERVICE_URL"),
  "PULSAR_SERVICE_URL is required (e.g. pulsar://my-broker:6650)");
builder.serviceUrl(url);

Prevention

When it happens

Trigger: Calling .serviceUrl(null) or .serviceUrl("") — typically an unset PULSAR_SERVICE_URL environment variable or missing config key in the deployment.

Common situations: Deployment manifests (Docker/K8s) where the Pulsar address env var is forgotten in one environment, or config templating leaves the value blank.

Related errors


AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14). Data as JSON: /api/errors/9fc64a20db25bc7f. Report an issue: GitHub.