{"record":{"id":"c306a90ee8dc4e9d","repo":"redisson/redisson","slug":"hibernate-cache-redisson-jndi-name-property-not-se","errorCode":null,"errorMessage":"hibernate.cache.redisson.jndi_name property not set","messagePattern":"hibernate\\.cache\\.redisson\\.jndi_name property not set","errorType":"exception","errorClass":"CacheException","httpStatus":null,"severity":"error","filePath":"redisson-hibernate/redisson-hibernate-4/src/main/java/org/redisson/hibernate/JndiRedissonRegionFactory.java","lineNumber":45,"sourceCode":"\r\n/**\r\n * Hibernate Cache region factory based on Redisson. \r\n * Uses Redisson instance located in JNDI.\r\n * \r\n * @author Nikita Koksharov \r\n *\r\n */\r\npublic class JndiRedissonRegionFactory extends RedissonRegionFactory {\r\n\r\n    private static final long serialVersionUID = -4814502675083325567L;\r\n\r\n    public static final String JNDI_NAME = CONFIG_PREFIX + \"jndi_name\";\r\n    \r\n    @Override\r\n    protected RedissonClient createRedissonClient(Properties properties) {\r\n        String jndiName = ConfigurationHelper.getString(JNDI_NAME, properties);\r\n        if (jndiName == null) {\r\n            throw new CacheException(JNDI_NAME + \" property not set\");\r\n        }\r\n        \r\n        Properties jndiProperties = JndiServiceImpl.extractJndiProperties(properties);\r\n        InitialContext context = null;\r\n        try {\r\n            context = new InitialContext(jndiProperties);\r\n            return (RedissonClient) context.lookup(jndiName);\r\n        } catch (NamingException e) {\r\n            throw new CacheException(\"Unable to locate Redisson instance by name: \" + jndiName, e);\r\n        } finally {\r\n            if (context != null) {\r\n                try {\r\n                    context.close();\r\n                } catch (NamingException e) {\r\n                    throw new CacheException(\"Unable to close JNDI context\", e);\r\n                }\r\n            }\r\n        }\r","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/redisson/redisson/blob/91188987c2a9023e7fedabff758681ad9b107f25/redisson-hibernate/redisson-hibernate-4/src/main/java/org/redisson/hibernate/JndiRedissonRegionFactory.java#L27-L63","documentation":"Thrown by RedissonClusterConnection when clusterGetNodes() output does not contain a node whose host/port match the requested master's InetSocketAddress. The loop compares master.getHost()/getPort() to each RedisClusterNode and throws IllegalStateException if no match is found. Typically the caller passed a node (or host:port) that is not a known master in the current cluster topology view.","triggerScenarios":"Calling cluster-get-slaves style operations on RedissonClusterConnection (e.g. clusterGetSlaves(node) / clusterGetMasterSlaveByMasterAddr or any API that internally resolves a master by address) with a RedisClusterNode or host:port that is not a master in the cluster (a replica address, a stale/removed node, or a wrong port). Also occurs if the cluster topology changed (reshard/failover) between fetching node info and the lookup, or if the cluster connection is actually pointed at a non-cluster deployment.","commonSituations":"Passing a replica node where a master is required; using a stale node list after failover; wrong port in the Spring node configuration (e.g. 6379 vs 7000); connecting a cluster connection factory to a single-instance Redis; DNS/NAT remapping so reported host differs from configured host.","solutions":["Verify the node you pass is a master: filter by RedisClusterNode.isMaster() or Role.MASTER before calling APIs that resolve masters by address.","Re-fetch the topology via clusterGetNodes() right before the call instead of caching node objects across failovers.","Check the host:port exactly matches what the cluster reports (cluster nodes output), including port and any announced-ip/announce-port NAT settings.","Confirm Redisson was configured with ClusterServersConfig and all seed nodes are reachable, so clusterGetNodes() returns the real topology."],"exampleFix":"// before\nRedisClusterNode node = clusterConnection.clusterGetNodes().iterator().next();\nCollection<RedisClusterNode> slaves = clusterConnection.clusterGetSlaves(node); // may throw if node is a replica\n\n// after\nRedisClusterNode master = clusterConnection.clusterGetNodes().stream()\n        .filter(RedisClusterNode::isMaster)\n        .findFirst()\n        .orElseThrow(() -> new IllegalStateException(\"no master in topology\"));\nCollection<RedisClusterNode> slaves = clusterConnection.clusterGetSlaves(master);","handlingStrategy":"validation","validationCode":"// before calling cluster master-resolution APIs\nRedisClusterNode master = clusterConn.clusterGetNodes().stream()\n        .filter(n -> n.isMaster()\n                && n.getHost().equals(requested.getHost())\n                && n.getPort() == requested.getPort())\n        .findFirst().orElse(null);\nif (master == null) {\n    // refresh topology or fail with clear message; do not call the API\n}","typeGuard":null,"tryCatchPattern":"catch (IllegalStateException e) when message starts with 'Unable to find master node': treat as stale/incorrect topology — refresh clusterGetNodes() and retry once, else surface configuration error.","preventionTips":["Always fetch node topology fresh via clusterGetNodes() before master-address-based calls; never cache RedisClusterNode across failovers.","Filter nodes by Role.MASTER before using them as master arguments.","Verify the Redisson config lists all cluster seed nodes with correct ports so topology discovery is accurate.","In NAT/docker environments, configure announced IPs so reported host:port match what you compare against."],"tags":["redis","redisson","cluster","topology","spring-data-redis"],"backgroundTag":null,"analyzedSha":"91188987c2a9023e7fedabff758681ad9b107f25","analyzedAt":"2026-08-14T11:39:42.619Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}