{"record":{"id":"714c8311fedd70c8","repo":"flowable/flowable-engine","slug":"could-not-lookup-beanmanager-in-jndi-using-name","errorCode":null,"errorMessage":"Could not lookup beanmanager in jndi using name: '${jndiName}'.","messagePattern":"Could not lookup beanmanager in jndi using name: '(.+?)'\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/util/BeanManagerLookup.java","lineNumber":42,"sourceCode":"    public static BeanManager localInstance;\r\n\r\n    /** provide a custom jndi lookup name */\r\n    public static String jndiName;\r\n\r\n    public static BeanManager getBeanManager() {\r\n        if (localInstance != null) {\r\n            return localInstance;\r\n        }\r\n        return lookupBeanManagerInJndi();\r\n    }\r\n\r\n    private static BeanManager lookupBeanManagerInJndi() {\r\n\r\n        if (jndiName != null) {\r\n            try {\r\n                return (BeanManager) InitialContext.doLookup(jndiName);\r\n            } catch (NamingException e) {\r\n                throw new FlowableException(\"Could not lookup beanmanager in jndi using name: '\" + jndiName + \"'.\", e);\r\n            }\r\n        }\r\n\r\n        try {\r\n            // in an application server\r\n            return (BeanManager) InitialContext.doLookup(\"java:comp/BeanManager\");\r\n        } catch (NamingException e) {\r\n            // silently ignore\r\n        }\r\n\r\n        try {\r\n            // in a servlet container\r\n            return (BeanManager) InitialContext.doLookup(\"java:comp/env/BeanManager\");\r\n        } catch (NamingException e) {\r\n            // silently ignore\r\n        }\r\n\r\n        throw new FlowableException(\"Could not lookup beanmanager in jndi. If no jndi is available, set the beanmanger to the 'localInstance' property of this class.\");\r","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/util/BeanManagerLookup.java#L24-L60","documentation":"BeanManagerLookup.lookupBeanManagerInJndi() throws FlowableException when an explicit JNDI name was configured but InitialContext.doLookup(name) throws NamingException. The configured JNDI name does not point to a bound javax.enterprise.inject.spi.BeanManager. The original NamingException is attached as the cause.","triggerScenarios":"BeanManagerLookup.jndiName was set (via flowable-cdi config or a custom jndi.properties) to a name under which no BeanManager is bound; InitialContext.doLookup(jndiName) fails with NamingException.","commonSituations":"Wrong JNDI name for the app server (e.g. Tomcat binds java:comp/env/BeanManager after CDI setup; WebSphere/WebLogic use different names); copying a JNDI name from a different container; missing resource reference in web.xml/ application-server config.","solutions":["Correct the configured jndiName to the BeanManager binding of your container (e.g. java:comp/BeanManager on Java EE, java:comp/env/BeanManager on servlet containers with Weld).","Skip JNDI entirely: call BeanManagerLookup.setLocalInstance(beanManager) at startup.","Verify the binding exists with a standalone JNDI dump / server console before wiring it.","Ensure the CDI provider (Weld/ OpenWebBeans) is actually installed and initialized in that deployment."],"exampleFix":"// before\nBeanManagerLookup.setJndiName(\"java:global/BeanManager\"); // not bound\n// after\nBeanManagerLookup.setJndiName(\"java:comp/BeanManager\");\n// or: BeanManagerLookup.setLocalInstance(beanManager);","handlingStrategy":"fallback","validationCode":"try {\n    new javax.naming.InitialContext().lookup(jndiName);\n} catch (javax.naming.NamingException e) {\n    BeanManagerLookup.setLocalInstance(cdiBeanManager); // fall back before engine starts\n}","typeGuard":"boolean jndiBeanManagerBound(String name) {\n    try { new javax.naming.InitialContext().lookup(name); return true; }\n    catch (javax.naming.NamingException e) { return false; }\n}","tryCatchPattern":"try {\n    bm = BeanManagerLookup.getBeanManager();\n} catch (org.flowable.common.engine.api.FlowableException e) {\n    bm = CDI.current().select(BeanManager.class).get(); // direct CDI container access\n}","preventionTips":["Confirm the JNDI binding with your container's console before configuring jndiName.","Prefer setLocalInstance over JNDI when embedding Flowable outside a full app server.","Attach resource-ref entries (web.xml/ server config) so the BeanManager is bound in java:comp.","Log the resolved JNDI name at startup to catch config drift."],"tags":["flowable","cdi","jndi","bean-manager"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}