{"record":{"id":"f49c20944a9f8921","repo":"heibaiying/BigData-Notes","slug":"jedis-configuration-not-found","errorCode":null,"errorMessage":"Jedis configuration not found","messagePattern":"Jedis configuration not found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"notes/Storm集成Redis详解.md","lineNumber":323,"sourceCode":"\n    private transient JedisCommandsInstanceContainer container;\n\n    private JedisPoolConfig jedisPoolConfig;\n    private JedisClusterConfig jedisClusterConfig;\n\n   ......\n   \n    @Override\n    public void prepare(Map map, TopologyContext topologyContext, OutputCollector collector) {\n        // FIXME: stores map (stormConf), topologyContext and expose these to derived classes\n        this.collector = collector;\n\n        if (jedisPoolConfig != null) {\n            this.container = JedisCommandsContainerBuilder.build(jedisPoolConfig);\n        } else if (jedisClusterConfig != null) {\n            this.container = JedisCommandsContainerBuilder.build(jedisClusterConfig);\n        } else {\n            throw new IllegalArgumentException(\"Jedis configuration not found\");\n        }\n    }\n\n  .......\n}\n```\n\n`JedisCommandsInstanceContainer` 的 `build()` 方法如下，实际上就是创建 JedisPool 或 JedisCluster 并传入容器中。\n\n```java\npublic static JedisCommandsInstanceContainer build(JedisPoolConfig config) {\n        JedisPool jedisPool = new JedisPool(DEFAULT_POOL_CONFIG, config.getHost(), config.getPort(), config.getTimeout(), config.getPassword(), config.getDatabase());\n        return new JedisContainer(jedisPool);\n    }\n\n public static JedisCommandsInstanceContainer build(JedisClusterConfig config) {\n        JedisCluster jedisCluster = new JedisCluster(config.getNodes(), config.getTimeout(), config.getTimeout(), config.getMaxRedirections(), config.getPassword(), DEFAULT_POOL_CONFIG);\n        return new JedisClusterContainer(jedisCluster);","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/heibaiying/BigData-Notes/blob/3898939aca387c25b3eb4e51ef49dfccca8543ed/notes/Storm集成Redis详解.md#L305-L341","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\npublic class MyRedisBolt extends AbstractRedisBolt {\n    public MyRedisBolt() {\n        super(); // no config forwarded -> \"Jedis configuration not found\" in prepare()\n    }\n}\n\n// after\npublic class MyRedisBolt extends AbstractRedisBolt {\n    public MyRedisBolt(JedisPoolConfig config) {\n        super(config);\n    }\n}\n// at topology assembly:\nnew MyRedisBolt(new JedisPoolConfig(\"127.0.0.1\", 6379, 2000, null, 0));","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(jedisPoolConfig != null ? jedisPoolConfig : jedisClusterConfig,\n    \"A JedisPoolConfig or JedisClusterConfig is required before building the topology\");\nRedisCountStoreBolt bolt = new RedisCountStoreBolt(jedisPoolConfig, storeMapper);","typeGuard":"boolean hasJedisConfig(org.apache.storm.redis.common.config.JedisPoolConfig pool,\n                          org.apache.storm.redis.common.config.JedisClusterConfig cluster) {\n    return pool != null || cluster != null;\n}","tryCatchPattern":"try {\n    bolt.prepare(conf, topologyContext, outputCollector);\n} catch (IllegalArgumentException e) {\n    if (\"Jedis configuration not found\".equals(e.getMessage())) {\n        // topology-assembly bug: rebuild bolt with new JedisPoolConfig(host, port, timeout, password, database)\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["storm","redis","jedis","configuration","topology","illegalargumentexception"],"backgroundTag":null,"analyzedSha":"3898939aca387c25b3eb4e51ef49dfccca8543ed","analyzedAt":"2026-08-14T15:36:11.245Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}