heibaiying/BigData-Notes · critical · IllegalArgumentException
Jedis configuration not found
Error message
Jedis configuration not found
What it means
This IllegalArgumentException is thrown from AbstractRedisBolt.prepare() (Apache Storm redis integration) when neither a JedisPoolConfig nor a JedisClusterConfig was supplied to the bolt's constructor. Every Redis bolt needs a Jedis commands container (wrapping a JedisPool or JedisCluster) before it can process tuples, and prepare() is the last point at which Storm can refuse to start the worker. It is a topology-assembly error: the topology fails during bolt initialization on the cluster.
Source
Thrown at notes/Storm集成Redis详解.md:323
private transient JedisCommandsInstanceContainer container;
private JedisPoolConfig jedisPoolConfig;
private JedisClusterConfig jedisClusterConfig;
......
@Override
public void prepare(Map map, TopologyContext topologyContext, OutputCollector collector) {
// FIXME: stores map (stormConf), topologyContext and expose these to derived classes
this.collector = collector;
if (jedisPoolConfig != null) {
this.container = JedisCommandsContainerBuilder.build(jedisPoolConfig);
} else if (jedisClusterConfig != null) {
this.container = JedisCommandsContainerBuilder.build(jedisClusterConfig);
} else {
throw new IllegalArgumentException("Jedis configuration not found");
}
}
.......
}
```
`JedisCommandsInstanceContainer` 的 `build()` 方法如下,实际上就是创建 JedisPool 或 JedisCluster 并传入容器中。
```java
public static JedisCommandsInstanceContainer build(JedisPoolConfig config) {
JedisPool jedisPool = new JedisPool(DEFAULT_POOL_CONFIG, config.getHost(), config.getPort(), config.getTimeout(), config.getPassword(), config.getDatabase());
return new JedisContainer(jedisPool);
}
public static JedisCommandsInstanceContainer build(JedisClusterConfig config) {
JedisCluster jedisCluster = new JedisCluster(config.getNodes(), config.getTimeout(), config.getTimeout(), config.getMaxRedirections(), config.getPassword(), DEFAULT_POOL_CONFIG);
return new JedisClusterContainer(jedisCluster);View on GitHub (pinned to 3898939aca)
Solutions
- Pass a valid config to the superclass constructor, e.g. super(new JedisPoolConfig(host, port, timeout, password, database)) or super(jedisClusterConfig) — never call super() empty.
- If config values come from a file, verify the resource is on the classpath and that host/port are non-null before building the bolt; log or assert them during topology main().
- If you subclassed AbstractRedisBolt yourself, add a constructor that mandates a config parameter so the mistake becomes a compile-time obligation instead of a runtime prepare() failure.
- If you intended a non-Redis bolt, extend BaseRichBolt instead of AbstractRedisBolt so no Jedis config is expected.
Example fix
// before
public class MyRedisBolt extends AbstractRedisBolt {
public MyRedisBolt() {
super(); // no config forwarded -> "Jedis configuration not found" in prepare()
}
}
// after
public class MyRedisBolt extends AbstractRedisBolt {
public MyRedisBolt(JedisPoolConfig config) {
super(config);
}
}
// at topology assembly:
new MyRedisBolt(new JedisPoolConfig("127.0.0.1", 6379, 2000, null, 0)); Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(jedisPoolConfig != null ? jedisPoolConfig : jedisClusterConfig,
"A JedisPoolConfig or JedisClusterConfig is required before building the topology");
RedisCountStoreBolt bolt = new RedisCountStoreBolt(jedisPoolConfig, storeMapper); Type guard
boolean hasJedisConfig(org.apache.storm.redis.common.config.JedisPoolConfig pool,
org.apache.storm.redis.common.config.JedisClusterConfig cluster) {
return pool != null || cluster != null;
} Try / catch
try {
bolt.prepare(conf, topologyContext, outputCollector);
} catch (IllegalArgumentException e) {
if ("Jedis configuration not found".equals(e.getMessage())) {
// topology-assembly bug: rebuild bolt with new JedisPoolConfig(host, port, timeout, password, database)
}
throw e;
} Prevention
- Never subclass AbstractRedisBolt with a no-arg super(); always forward a JedisPoolConfig or JedisClusterConfig.
- Validate loaded Redis host/port are non-null right after reading config files, before topology submission.
- Add a constructor overload in custom bolts that requires a config parameter, making omission a compile error.
- Run the topology once in LocalCluster as a smoke test before cluster deployment.
When it happens
Trigger: Instantiating AbstractRedisBolt (or a subclass like RedisStoreBolt / RedisCountStoreBolt / RedisFilterBolt / RedisLookupBolt) via a constructor path that leaves both jedisPoolConfig and jedisClusterConfig null — typically subclassing AbstractRedisBolt and calling super() with no arguments, or passing a null config. The exception fires when Storm calls prepare() for that bolt on the worker, before any tuple is processed.
Common situations: Custom bolts that extend AbstractRedisBolt but forget to forward a JedisPoolConfig/JedisClusterConfig to super(); NPE-prone config loading (e.g. reading Redis host from a properties/yaml file that is missing or not on the classpath, yielding null); refactoring from single-node JedisPoolConfig to a JedisClusterConfig and accidentally dropping both; unit tests that construct the bolt without any Redis config.
Related errors
- Cannot process such data type for Count: ${dataType}
- Cannot process such data type: ${dataType}
- Cannot process such data type for Count: ${dataType}
- value structure should be longitude:latitude
AI-assisted analysis of heibaiying/BigData-Notes@3898939aca (2026-08-14).
Data as JSON: /api/errors/f49c20944a9f8921.
Report an issue: GitHub.