{"record":{"id":"a8e359421ddf7594","repo":"deeplearning4j/deeplearning4j","slug":"error-reading-uri-file","errorCode":null,"errorMessage":"Error reading URI file","messagePattern":"Error reading URI file","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/jackson/JacksonRecordReader.java","lineNumber":118,"sourceCode":"    @Override\n    public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {\n        initialize(split);\n    }\n\n    @Override\n    public List<Writable> next() {\n        if (uris == null)\n            throw new IllegalStateException(\"URIs are null. Not initialized?\");\n        if (!hasNext())\n            throw new NoSuchElementException(\"No next element\");\n\n        URI uri = uris[cursor++];\n        invokeListeners(uri);\n        String fileAsString;\n        try (InputStream s = streamCreatorFn.apply(uri)){\n            fileAsString = IOUtils.toString(s, charset);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Error reading URI file\", e);\n        }\n\n        return readValues(uri, fileAsString);\n\n    }\n\n    @Override\n    public boolean hasNext() {\n        return cursor < uris.length;\n    }\n\n    @Override\n    public List<String> getLabels() {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public void reset() {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/jackson/JacksonRecordReader.java#L100-L136","documentation":"JacksonRecordReader.next() wraps any IOException raised while opening or reading the InputStream for the current URI into a RuntimeException with message 'Error reading URI file'. It means the underlying JSON file could not be read (missing file, permission problem, or stream failure), not that the JSON content was invalid. The original IOException is chained as the cause.","triggerScenarios":"streamCreatorFn.apply(uri) fails to open the URI, or IOUtils.toString throws IOException mid-read during next().","commonSituations":"InputSplit URIs pointing to files deleted or moved after split creation; unreadable file permissions; network/DFS URI that dropped; wrong charset on a corrupted stream.","solutions":["Verify every URI in the InputSplit exists and is readable before initialize()","Catch IOException/RuntimeException in the caller and inspect the chained cause","Regenerate the InputSplit if files moved or were deleted","Check filesystem/DFS permissions for the process user"],"exampleFix":"// before\nreader.initialize(conf, split); // stale split, files moved\nList<Writable> r = reader.next();\n// after\nFile f = new File(uri.getPath());\nif (!f.isFile() || !f.canRead()) throw new IllegalStateException(\"Missing input file: \" + uri);\nreader.initialize(conf, split);\nList<Writable> r = reader.next();","handlingStrategy":"try-catch","validationCode":"for (URI u : uris) { File f = new File(u.getPath()); if (!f.isFile() || !f.canRead()) throw new IllegalStateException(\"Unreadable: \" + u); }","typeGuard":null,"tryCatchPattern":"try { List<Writable> r = reader.next(); } catch (RuntimeException e) { IOException cause = (IOException) e.getCause(); log.error(\"URI read failed: \"+cause.getMessage(), cause); }","preventionTips":["Validate split URIs before initialize","Keep source files in place for the whole job","Run the reader as a user with read access to the data directory"],"tags":["java","io","file-read","runtime-exception"],"backgroundTag":"file-read-failed","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}