{"record":{"id":"2cdbd5542490f1d0","repo":"redisson/redisson","slug":"hibernate-cache-redisson-jndi-name-property-not-se-2cdbd5","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":"critical","filePath":"redisson-hibernate/redisson-hibernate-6/src/main/java/org/redisson/hibernate/JndiRedissonRegionNativeFactory.java","lineNumber":44,"sourceCode":"\n/**\n * Hibernate Cache region factory based on Redisson. \n * Uses Redisson instance located in JNDI.\n * \n * @author Nikita Koksharov \n *\n */\npublic class JndiRedissonRegionNativeFactory extends RedissonRegionNativeFactory {\n\n    private static final long serialVersionUID = -4814502675083325567L;\n\n    public static final String JNDI_NAME = CONFIG_PREFIX + \"jndi_name\";\n    \n    @Override\n    protected RedissonClient createRedissonClient(StandardServiceRegistry registry, Map properties) {\n        String jndiName = ConfigurationHelper.getString(JNDI_NAME, properties);\n        if (jndiName == null) {\n            throw new CacheException(JNDI_NAME + \" property not set\");\n        }\n\n        try {\n            return (RedissonClient) registry.getService(JndiService.class).locate(jndiName);\n        } catch (JndiException e) {\n            throw new CacheException(e);\n        }\n    }\n\n    @Override\n    protected void releaseFromUse() {\n    }\n\n}\n","sourceCodeStart":26,"sourceCodeEnd":59,"githubUrl":"https://github.com/redisson/redisson/blob/91188987c2a9023e7fedabff758681ad9b107f25/redisson-hibernate/redisson-hibernate-6/src/main/java/org/redisson/hibernate/JndiRedissonRegionNativeFactory.java#L26-L59","documentation":"JndiRedissonRegionFactory (and its Native variant) builds its RedissonClient by looking one up in JNDI instead of creating one from a config file. The required property hibernate.cache.redisson.jndi_name is read with ConfigurationHelper.getString; when absent, CacheException('<key> property not set') is thrown at cache startup.","triggerScenarios":"Setting cache.region_factory to JndiRedissonRegionFactory (or JndiRedissonRegionNativeFactory) without defining the hibernate.cache.redisson.jndi_name property in the Hibernate configuration.","commonSituations":"Migrating an app to an app-server-managed Redisson but forgetting the jndi_name property; property name typos (jndiName vs jndi_name); the name present in one persistence unit but not another; running unit tests outside the container where no JNDI exists.","solutions":["Add <property name=\"hibernate.cache.redisson.jndi_name\" value=\"redisson\"/> (or your binding) to persistence.xml / hibernate.cfg.xml.","Bind a RedissonClient instance into the app server's JNDI tree under exactly that name (WildFly: java:global/redisson via a resource adapter or @Produces; Tomcat: Resource in context.xml).","Verify the binding with a JNDI lookup before starting Hibernate; a wrong name later surfaces as CacheException(JndiException).","For non-container environments use RedissonRegionFactory with redisson.yaml instead of the JNDI variant."],"exampleFix":"// before\n<property name=\"hibernate.cache.region.factory_class\"\n          value=\"org.redisson.hibernate.JndiRedissonRegionFactory\"/>\n<!-- no jndi_name -> CacheException -->\n\n// after\n<property name=\"hibernate.cache.region.factory_class\"\n          value=\"org.redisson.hibernate.JndiRedissonRegionFactory\"/>\n<property name=\"hibernate.cache.redisson.jndi_name\" value=\"redisson\"/>","handlingStrategy":"validation","validationCode":"// Verify the property and binding before Hibernate boots\nString jndiName = (String) props.get(\"hibernate.cache.redisson.jndi_name\");\nif (jndiName == null || jndiName.isBlank()) {\n    throw new IllegalStateException(\"hibernate.cache.redisson.jndi_name is required for JndiRedissonRegionFactory\");\n}\nnew InitialContext().lookup(jndiName); // throws NameNotFoundException early if unbound","typeGuard":null,"tryCatchPattern":"try {\n    sessionFactory = metadata.buildSessionFactory();\n} catch (CacheException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"jndi_name property not set\")) {\n        throw new BootstrapException(\"Set hibernate.cache.redisson.jndi_name and bind a RedissonClient in JNDI\", e);\n    }\n    throw e;\n}","preventionTips":["Always pair JndiRedissonRegionFactory with the hibernate.cache.redisson.jndi_name property — the factory has no default.","Bind and smoke-test the JNDI entry with a standalone lookup before starting Hibernate.","In tests outside a container, fall back to RedissonRegionFactory with a classpath redisson.yaml."],"tags":["redisson","hibernate","jndi","cache","configuration","native"],"backgroundTag":null,"analyzedSha":"91188987c2a9023e7fedabff758681ad9b107f25","analyzedAt":"2026-08-14T11:39:42.619Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}