{"record":{"id":"987ab25fac7f23cf","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-myid-properties-file-zk-config-file","errorCode":null,"errorMessage":"can't find myid properties file : ${ZK_CONFIG_FILE_NAME}","messagePattern":"can't find myid properties file : (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java","lineNumber":114,"sourceCode":"\n    /**\n     * 加载myid配制文件信息\n    * 方法描述\n    * @return\n    * @创建日期 2016年9月15日\n    */\n    private static Properties LoadMyidPropersites() {\n        Properties pros = new Properties();\n\n        try (InputStream configIS = ZkConfig.class.getResourceAsStream(ZK_CONFIG_FILE_NAME)) {\n            if (configIS == null) {\n                return null;\n            }\n\n            pros.load(configIS);\n        } catch (IOException e) {\n            LOGGER.error(\"ZkConfig LoadMyidPropersites error:\", e);\n            throw new RuntimeException(\"can't find myid properties file : \" + ZK_CONFIG_FILE_NAME);\n        }\n\n        // validate\n        String zkURL = pros.getProperty(ZkParamCfg.ZK_CFG_URL.getKey());\n        String myid = pros.getProperty(ZkParamCfg.ZK_CFG_MYID.getKey());\n\n        String clusterId = pros.getProperty(ZkParamCfg.ZK_CFG_CLUSTERID.getKey());\n\n        if (Strings.isNullOrEmpty(clusterId) ||Strings.isNullOrEmpty(zkURL) || Strings.isNullOrEmpty(myid)) {\n            throw new RuntimeException(\"clusterId and zkURL and myid must not be null or empty!\");\n        }\n        return pros;\n\n    }\n\n    public static void main(String[] args) {\n        String zk = ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_CLUSTERID);\n        System.out.println(zk);","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java#L96-L132","documentation":"ZkConfig.LoadMyidPropersites loads the ZooKeeper myid properties file named by ZK_CONFIG_FILE_NAME (typically zkcnf/myid.properties). When the file exists on the classpath but reading its stream throws an IOException, the catch block logs and rethrows as a RuntimeException. This means the file was found but could not be read/parsed.","triggerScenarios":"pros.load(configIS) throws IOException while reading the stream opened for ZK_CONFIG_FILE_NAME; the RuntimeException is thrown at ZkConfig.java:114 during startup when ZkConfig.main / static init calls LoadMyidPropersites.","commonSituations":"myid.properties exists but is unreadable due to file permissions, a truncated or empty file, a jar-packaged resource that failed to open, wrong encoding, or the file being locked/replaced while the classloader stream is opened.","solutions":["Check the logged 'ZkConfig LoadMyidPropersites error' IOException cause for the real reason (permission, truncation, etc.).","Verify zkcnf/myid.properties (or ZK_CONFIG_FILE_NAME) exists on the classpath and is readable by the Mycat process user (chmod/chown).","Recreate the file with the required keys (zkURL, clusterId, myid) and valid properties syntax.","Confirm the resource is packaged inside the jar/deployment if running from a fat jar."],"exampleFix":"// before: unreadable/missing content in myid.properties\n\n// after: recreate readable file with required keys\nzkURL=127.0.0.1:2181\nclusterId=cluster-1\nmyid=1","handlingStrategy":"validation","validationCode":"java.io.InputStream is = getClass().getResourceAsStream(zkConfigFileName);\nif (is == null) throw new IllegalStateException(\"missing \" + zkConfigFileName);\nProperties p = new Properties();\ntry (is) { p.load(is); } catch (IOException e) { throw new IllegalStateException(\"unreadable \" + zkConfigFileName, e); }","typeGuard":null,"tryCatchPattern":"try { ZkConfig.initZk(); } catch (RuntimeException e) { if (e.getMessage().contains(\"can't find myid properties file\")) { log.error(\"Check {} readability/permissions on classpath\", ZK_CONFIG_FILE_NAME, e); } throw e; }","preventionTips":["Keep myid.properties readable by the Mycat service user","Verify the file inside deployed jars/wars after packaging","Check file permissions after deployments and config syncs","Read the logged IOException cause before guessing"],"tags":["zookeeper","config","io","runtime","mycat"],"backgroundTag":"file-read-failed","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"}