{"record":{"id":"b5771b84086f178b","repo":"apache/pulsar","slug":"schema-file-s-is-not-found-relative-path-s-is-r","errorCode":null,"errorMessage":"Schema file %s is not found. Relative path %s is resolved to %s. Try to use absolute path if the relative one resolved wrongly.","messagePattern":"Schema file (.+?) is not found\\. Relative path (.+?) is resolved to (.+?)\\. Try to use absolute path if the relative one resolved wrongly\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java","lineNumber":132,"sourceCode":"        private String topicName;\n\n        @Option(names = { \"-f\", \"--filename\" }, description = \"filename\", required = true)\n        private String schemaFileName;\n\n        @Override\n        void run() throws Exception {\n            String topic = validateTopicName(topicName);\n            Path schemaPath = Path.of(schemaFileName);\n            File schemaFile = schemaPath.toFile();\n            if (!schemaFile.exists()) {\n                final StringBuilder sb = new StringBuilder();\n                sb.append(\"Schema file \").append(schemaPath).append(\" is not found.\");\n                if (!schemaPath.isAbsolute()) {\n                    sb.append(\" Relative path \").append(schemaPath)\n                            .append(\" is resolved to \").append(schemaPath.toAbsolutePath())\n                            .append(\". Try to use absolute path if the relative one resolved wrongly.\");\n                }\n                throw new FileNotFoundException(sb.toString());\n            }\n            PostSchemaPayload input = MAPPER.readValue(schemaFile, PostSchemaPayload.class);\n            getAdmin().schemas().createSchema(topic, input);\n        }\n    }\n\n    @Command(description = \"Provide the schema via a topic\")\n    private class ExtractSchema extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Option(names = { \"-j\", \"--jar\" }, description = \"jar filepath\", required = true)\n        private String jarFilePath;\n\n        @Option(names = { \"-t\", \"--type\" }, description = \"type avro or json\", required = true)\n        private String type;\n\n        @Option(names = { \"-c\", \"--classname\" }, description = \"class name of pojo\", required = true)","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java#L114-L150","documentation":"`pulsar-admin schemas upload` reads the schema definition from a file given by --schema-file. If the resolved path does not exist, a FileNotFoundException is thrown with an extended message showing how a relative path was resolved (against the process working directory) and advising an absolute path.","triggerScenarios":"Running `pulsar-admin schemas upload` with a --schema-file path that does not exist, or a relative path resolved against a different working directory than the user expected (e.g. running from systemd, another cwd, or a wrapper script).","commonSituations":"Typos in filename; running the CLI from a different directory than intended in cron/systemd/CI; the schema file was deleted or not mounted in a container; assuming resolution relative to the topic or config file rather than cwd.","solutions":["Use an absolute path: --schema-file /etc/pulsar/schema/my-schema.json","Check the 'is resolved to' portion of the message to see the directory the CLI is actually running from","Verify the file exists (ls) and is readable by the user running pulsar-admin","Fix the working directory of scripts/services that invoke the CLI"],"exampleFix":"// before\npulsar-admin schemas upload --topic t --schema-file schema.json\n// after\npulsar-admin schemas upload --topic t --schema-file /opt/schemas/schema.json","handlingStrategy":"validation","validationCode":"java.nio.file.Path p = java.nio.file.Paths.get(schemaFile);\nif (!java.nio.file.Files.isRegularFile(p)) {\n    throw new IllegalArgumentException(\"Schema file not found: \" + p.toAbsolutePath());\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.schemas().createSchema(topic, payload);\n} catch (java.io.FileNotFoundException e) {\n    // resolve schema file against the correct directory or switch to absolute path\n}","preventionTips":["Always use absolute paths for --schema-file in scripts and services","Log/verify the process working directory in cron, systemd, and CI runners","Mount schema files into containers and check readability before upload"],"tags":["cli","schema","file-not-found","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}