{"record":{"id":"0bbf82252226b42a","repo":"MyCATApache/Mycat-Server","slug":"cachepoolfactory-not-defined-for-type-type","errorCode":null,"errorMessage":"CachePoolFactory not defined for type:{type}","messagePattern":"CachePoolFactory not defined for type:(.+?)","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/cache/CacheService.java","lineNumber":162,"sourceCode":"\t\t\t\tfactryClassName).newInstance();\n\t\tpoolFactorys.put(factryType, factry);\n\n\t}\n\n\tprivate void createPool(String poolName, String type, int cacheSize,\n\t\t\tint expireSeconds) {\n\t\tcheckExists(poolName);\n\t\tCachePoolFactory cacheFact = getCacheFact(type);\n\t\tCachePool cachePool = cacheFact.createCachePool(poolName, cacheSize,\n\t\t\t\texpireSeconds);\n\t\tallPools.put(poolName, cachePool);\n\n\t}\n\n\tprivate CachePoolFactory getCacheFact(String type) {\n\t\tCachePoolFactory facty = this.poolFactorys.get(type);\n\t\tif (facty == null) {\n\t\t\tthrow new RuntimeException(\"CachePoolFactory not defined for type:\"\n\t\t\t\t\t+ type);\n\t\t}\n\t\treturn facty;\n\t}\n\n\t/**\n\t * get cache pool by name ,caller should cache result\n\t * \n\t * @param poolName\n\t * @return CachePool\n\t */\n\tpublic CachePool getCachePool(String poolName) {\n\t\tCachePool pool = allPools.get(poolName);\n\t\tif (pool == null) {\n\t\t\tthrow new IllegalArgumentException(\"can't find cache pool:\"\n\t\t\t\t\t+ poolName);\n\t\t} else {\n\t\t\treturn pool;","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/cache/CacheService.java#L144-L180","documentation":"CacheService looks up a CachePoolFactory by cache type string (e.g. 'ehcache', 'leveldb', 'map') in the poolFactorys map populated from cache config. If the configured cache type has no registered factory, it throws this RuntimeException instead of returning a factory. It is a startup/config-level contract error: Mycat only supports the cache types it has factory implementations for.","triggerScenarios":"A cache name in the Mycat cache configuration (e.g. server.xml/ehcache section or cachecfg) declares a type string that does not match any registered CachePoolFactory key, so getCacheFact(type) finds no entry when layerdPool or cacheFact builds the pool.","commonSituations":"Typo in the cache type attribute; copying a cache config from another Mycat version where a factory type was renamed/removed; enabling a type like 'enjoyredis' or custom type without the matching plugin on the classpath; case-sensitivity mismatch ('Ehcache' vs 'ehcache').","solutions":["Open your cache configuration and correct the cache type string to one Mycat supports (e.g. 'ehcache', 'map', 'leveldb')","Check which CachePoolFactory classes are registered (io.mycat.cache package) and use exactly their type key, matching case","Remove or comment out cache entries whose factory type is not available in your Mycat build","If a custom cache type is intended, implement/verify the CachePoolFactory plugin is on the classpath and registered"],"exampleFix":"// before (cache config)\n<cache name=\"sqlRouteCache\" type=\"encache\" ... />\n// after\n<cache name=\"sqlRouteCache\" type=\"ehcache\" ... />","handlingStrategy":"validation","validationCode":"// before starting pools, validate cache types against available factories\nSet<String> supported = CacheServiceProvider.loadFactories().stream()\n    .map(CachePoolFactory::getName).collect(Collectors.toSet());\nfor (String type : configuredCacheTypes) {\n    if (!supported.contains(type)) {\n        throw new IllegalArgumentException(\"Unsupported cache type: \" + type + \", supported: \" + supported);\n    }\n}","typeGuard":"boolean isSupportedCacheType(String type) {\n    return type != null && CacheService.getStaticCaps().keySet().contains(type);\n}","tryCatchPattern":"try {\n    CachePool pool = cacheService.getCachePool(poolName);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"CachePoolFactory not defined for type\")) {\n        LOG.error(\"Bad cache type in config: {}\", e.getMessage());\n        throw new ConfigurationException(e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Keep cache type strings exactly matching factory keys (lowercase, no typos)","Validate the cache config at deploy time against supported factory types","After a Mycat version upgrade, diff cache config types against the new release's supported factories"],"tags":["cache","configuration","runtime","mycat"],"backgroundTag":"invalid-config-value","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}