{"record":{"id":"e46fc9bb0261d248","repo":"flowable/flowable-engine","slug":"could-not-lookup-beanmanager-in-jndi-if-no-jndi-i","errorCode":null,"errorMessage":"Could not lookup beanmanager in jndi. If no jndi is available, set the beanmanger to the 'localInstance' property of this class.","messagePattern":"Could not lookup beanmanager in jndi\\. If no jndi is available, set the beanmanger to the 'localInstance' property of this class\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/util/BeanManagerLookup.java","lineNumber":60,"sourceCode":"                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\n    }\r\n}\r\n","sourceCodeStart":42,"sourceCodeEnd":63,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/util/BeanManagerLookup.java#L42-L63","documentation":"BeanManagerLookup.lookupBeanManagerInJndi() throws FlowableException after all standard JNDI lookups fail: the explicitly configured name (if any), java:comp/BeanManager (application server) and java:comp/env/BeanManager (servlet container) all raised NamingException. The message instructs users to provide the BeanManager via the static localInstance property instead.","triggerScenarios":"getBeanManager() runs in an environment without CDI bindings in JNDI — plain Java SE, Spring Boot, unit tests, or a servlet container without a working CDI provider — and no localInstance was set.","commonSituations":"Running flowable-cdi in tests without an app server; Spring Boot apps including CDI modules; servlet container where Weld wasn't registered so java:comp/env/BeanManager is absent.","solutions":["At startup call BeanManagerLookup.setLocalInstance(beanManager) with the BeanManager from your CDI container (e.g. CDI.current().select(BeanManager.class).get()).","Remove flowable-cdi if CDI is not used in the deployment.","Install/ correctly configure the CDI provider (Weld servlet initializer, beans.xml) so the standard JNDI names exist.","If a custom JNDI name is valid in your container, set BeanManagerLookup.setJndiName(...) to it so the lookup succeeds."],"exampleFix":"// before: engine boots in a test with no CDI in JNDI\n// after\nBeanManagerLookup.setLocalInstance(CDI.current().select(BeanManager.class).get());","handlingStrategy":"fallback","validationCode":"try {\n    new javax.naming.InitialContext().lookup(\"java:comp/BeanManager\");\n} catch (javax.naming.NamingException e) {\n    // no JNDI CDI binding: set local instance before engine use\n    BeanManagerLookup.setLocalInstance(CDI.current().select(BeanManager.class).get());\n}","typeGuard":"boolean jndiHasBeanManager() {\n    try { new javax.naming.InitialContext().lookup(\"java:comp/BeanManager\"); 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();\n}","preventionTips":["In SE/ test/ Spring environments always set BeanManagerLookup.setLocalInstance at boot.","Install the CDI provider (Weld initializer) when running in servlet containers.","Remove flowable-cdi from non-CDI deployments.","Do a startup sanity lookup of java:comp/BeanManager to fail fast."],"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"}