openzipkin/zipkin · error · NullPointerException
connectionFactory == null
Error message
connectionFactory == null
What it means
ActiveMQCollector.Builder.connectionFactory rejects null because the collector needs a configured ActiveMQConnectionFactory to create connections and message listeners on the zipkin queue. Unlike metrics/storage, there is no default: an ActiveMQ broker connection is mandatory for this collector type.
Source
Thrown at zipkin-collector/activemq/src/main/java/zipkin2/collector/activemq/ActiveMQCollector.java:50
@Override public Builder storage(StorageComponent storage) {
this.delegate.storage(storage);
return this;
}
@Override public Builder sampler(CollectorSampler sampler) {
this.delegate.sampler(sampler);
return this;
}
@Override public Builder metrics(CollectorMetrics metrics) {
if (metrics == null) throw new NullPointerException("metrics == null");
this.metrics = metrics.forTransport("activemq");
this.delegate.metrics(this.metrics);
return this;
}
public Builder connectionFactory(ActiveMQConnectionFactory connectionFactory) {
if (connectionFactory == null) throw new NullPointerException("connectionFactory == null");
this.connectionFactory = connectionFactory;
return this;
}
/** Queue zipkin spans will be consumed from. Defaults to "zipkin". */
public Builder queue(String queue) {
if (queue == null) throw new NullPointerException("queue == null");
this.queue = queue;
return this;
}
/** Count of concurrent message listeners on the queue. Defaults to 1 */
public Builder concurrency(int concurrency) {
if (concurrency < 1) throw new IllegalArgumentException("concurrency < 1");
this.concurrency = concurrency;
return this;
}
View on GitHub (pinned to 878ce2a1fa)
Solutions
- Create and set the factory from the broker URL: new ActiveMQConnectionFactory("tcp://broker:61616") then pass it.
- Verify the broker URL configuration property is present before building the collector.
- In tests, use an embedded broker (e.g. vm://localhost) instead of passing null.
Example fix
// before
ActiveMQCollector.newBuilder(SERVER).connectionFactory(null); // NPE
// after
ActiveMQCollector.newBuilder(SERVER)
.connectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616")); Defensive patterns
Strategy: validation
Validate before calling
java Objects.requireNonNull(brokerUrl, "broker URL must be configured"); builder.connectionFactory(new ActiveMQConnectionFactory(brokerUrl));
Prevention
- Validate required config (broker URL) at startup with a clear message before touching builders.
- Fail fast on missing env vars instead of forwarding nulls.
When it happens
Trigger: Calling .connectionFactory(null) on the ActiveMQ collector builder — usually an unset broker URL property being passed straight through.
Common situations: Missing ACTIVEMQ_URL/broker configuration in env-driven setup; unit tests building the collector without a broker; refactoring that dropped the factory creation line.
Related errors
AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14).
Data as JSON: /api/errors/fae09e1ac964becf.
Report an issue: GitHub.