{"record":{"id":"4389ae92f703d787","repo":"alibaba/druid","slug":"illegal-maxactive","errorCode":null,"errorMessage":"illegal maxActive {}","messagePattern":"illegal maxActive (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java","lineNumber":719,"sourceCode":"            if (this.dbTypeName == null || this.dbTypeName.length() == 0) {\n                this.dbTypeName = JdbcUtils.getDbType(jdbcUrl, null);\n            }\n\n            DbType dbType = DbType.of(this.dbTypeName);\n            if (JdbcUtils.isMysqlDbType(dbType)) {\n                boolean cacheServerConfigurationSet = false;\n                if (this.connectProperties.containsKey(\"cacheServerConfiguration\")) {\n                    cacheServerConfigurationSet = true;\n                } else if (this.jdbcUrl.indexOf(\"cacheServerConfiguration\") != -1) {\n                    cacheServerConfigurationSet = true;\n                }\n                if (cacheServerConfigurationSet) {\n                    this.connectProperties.put(\"cacheServerConfiguration\", \"true\");\n                }\n            }\n\n            if (maxActive <= 0) {\n                throw new IllegalArgumentException(\"illegal maxActive \" + maxActive);\n            }\n\n            if (maxActive < minIdle) {\n                throw new IllegalArgumentException(\"illegal maxActive \" + maxActive);\n            }\n\n            if (getInitialSize() > maxActive) {\n                throw new IllegalArgumentException(\"illegal initialSize \" + this.initialSize + \", maxActive \" + maxActive);\n            }\n\n            if (timeBetweenLogStatsMillis > 0 && useGlobalDataSourceStat) {\n                throw new IllegalArgumentException(\"timeBetweenLogStatsMillis not support useGlobalDataSourceStat=true\");\n            }\n\n            if (maxEvictableIdleTimeMillis < minEvictableIdleTimeMillis) {\n                throw new SQLException(\"maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis\");\n            }\n","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java#L701-L737","documentation":"IllegalArgumentException('illegal maxActive <val>') thrown during init() when maxActive <= 0. At init time the pool materializes arrays sized by maxActive, so a non-positive value is impossible to honor and is rejected before any connection is created.","triggerScenarios":"init() runs with this.maxActive <= 0 (e.g. 0, negative). The check at line 718 throws. Distinguished from setMaxActive(0) because this catches a stale/never-set field at init time.","commonSituations":"maxActive never configured and a default resolved to 0/negative; properties override set it to 0; programmatic construction without setMaxActive; bad env var parsing.","solutions":["Set maxActive to a positive value before init (dataSource.setMaxActive(10)).","Provide druid.maxActive in properties with a sane default.","Validate config at application startup and fail fast with a clear message if maxActive is missing."],"exampleFix":"// before\nDruidDataSource ds = new DruidDataSource();\nds.setUrl(url);\nds.init(); // maxActive still 0 -> illegal\n// after\nDruidDataSource ds = new DruidDataSource();\nds.setUrl(url);\nds.setMaxActive(10);\nds.init();","handlingStrategy":"validation","validationCode":"if (dataSource.getMaxActive() <= 0) {\n    throw new IllegalStateException(\"maxActive must be > 0 before init; current=\" + dataSource.getMaxActive());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set maxActive explicitly during construction.","Validate required config in a startup bean before init().","Log resolved config to catch missing values early."],"tags":["config","pool-sizing","init","validation"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}