{"record":{"id":"e2967ec8cefffaba","repo":"flowable/flowable-engine","slug":"couldn-t-lookup-datasource-from","errorCode":null,"errorMessage":"couldn't lookup datasource from ","messagePattern":"couldn't lookup datasource from ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/AbstractEngineConfiguration.java","lineNumber":426,"sourceCode":"     */\n    protected VariableLengthVerifier variableLengthVerifier = NoopVariableLengthVerifier.INSTANCE;\n\n    protected VariableValueConversionHandler variableValueConversionHandler;\n\n    protected void initEngineConfigurations() {\n        addEngineConfiguration(getEngineCfgKey(), getEngineScopeType(), this);\n    }\n\n    // DataSource\n    // ///////////////////////////////////////////////////////////////\n\n    protected void initDataSource() {\n        if (dataSource == null) {\n            if (dataSourceJndiName != null) {\n                try {\n                    dataSource = (DataSource) new InitialContext().lookup(dataSourceJndiName);\n                } catch (Exception e) {\n                    throw new FlowableException(\"couldn't lookup datasource from \" + dataSourceJndiName + \": \" + e.getMessage(), e);\n                }\n\n            } else if (jdbcUrl != null) {\n                if ((jdbcDriver == null) || (jdbcUsername == null)) {\n                    throw new FlowableException(\"DataSource or JDBC properties have to be specified in a process engine configuration\");\n                }\n\n                logger.debug(\"initializing datasource to db: {}\", jdbcUrl);\n\n                if (logger.isInfoEnabled()) {\n                    logger.info(\"Configuring Datasource with following properties (omitted password for security)\");\n                    logger.info(\"datasource driver : {}\", jdbcDriver);\n                    logger.info(\"datasource url : {}\", jdbcUrl);\n                    logger.info(\"datasource user name : {}\", jdbcUsername);\n                }\n\n                PooledDataSource pooledDataSource = new PooledDataSource(this.getClass().getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword);\n","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/AbstractEngineConfiguration.java#L408-L444","documentation":"During engine configuration, if no DataSource was set directly, the engine tries to look one up from JNDI using the configured dataSourceJndiName. If the InitialContext lookup fails for any reason, this FlowableException wraps the underlying cause.","triggerScenarios":"AbstractEngineConfiguration.initDataSource() with dataSource == null and dataSourceJndiName != null, where InitialContext().lookup(jndiName) throws (name not bound, no JNDI provider, wrong name, naming exception).","commonSituations":"Deploying outside an app server (no JNDI), typo in the JNDI name, datasource not declared in the container (e.g. missing resource definition in Tomcat/WildFly), missing jee jar on classpath in Spring Boot.","solutions":["Verify the exact JNDI name exists in the container and matches dataSourceJndiName","Declare the datasource resource in the application server configuration (context.xml / server datasource)","Alternatively set the dataSource object directly or use jdbcUrl/jdbcDriver/jdbcUsername/jdbcPassword instead of JNDI"],"exampleFix":"// before\nprocessEngineConfiguration.setDataSourceJndiName(\"java:/comp/env/jdbc/flowable\");\n// after\nprocessEngineConfiguration.setDataSource(dataSource); // or use setJdbcUrl/setJdbcDriver/setJdbcUsername/setJdbcPassword","handlingStrategy":"validation","validationCode":"if (config.getDataSource() == null && config.getDataSourceJndiName() != null) { try { new InitialContext().lookup(config.getDataSourceJndiName()); } catch (NamingException e) { throw new IllegalStateException(\"JNDI datasource not found: \" + config.getDataSourceJndiName(), e); } }","typeGuard":null,"tryCatchPattern":"try { engine = cfg.buildProcessEngine(); } catch (FlowableException e) { if (e.getMessage().startsWith(\"couldn't lookup datasource\")) { /* fall back to direct DataSource */ } throw e; }","preventionTips":["Verify JNDI binding exists in the target environment before deployment","Prefer injecting a DataSource directly (Spring/boot) over JNDI lookup","Use the same JNDI name constants in config and container descriptor"],"tags":["flowable","jndi","datasource","configuration"],"backgroundTag":"missing-dependency","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}