{"record":{"id":"b89be1aff311f468","repo":"stanfordnlp/CoreNLP","slug":"file-problem-e","errorCode":null,"errorMessage":"File problem: <e>","messagePattern":"File problem: <e>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/QPTreeTransformer.java","lineNumber":168,"sourceCode":"  }\n\n\n  public static void main(String[] args) {\n\n    QPTreeTransformer transformer = new QPTreeTransformer();\n    Treebank tb = new MemoryTreebank();\n    Properties props = StringUtils.argsToProperties(args);\n    String treeFileName = props.getProperty(\"treeFile\");\n\n    if (treeFileName != null) {\n      try {\n        TreeReader tr = new PennTreeReader(new BufferedReader(new InputStreamReader(new FileInputStream(treeFileName))), new LabeledScoredTreeFactory());\n        Tree t;\n        while ((t = tr.readTree()) != null) {\n          tb.add(t);\n        }\n      } catch (IOException e) {\n        throw new RuntimeException(\"File problem: \" + e);\n      }\n\n    }\n\n    for (Tree t : tb) {\n      System.out.println(\"Original tree\");\n      t.pennPrint();\n      System.out.println();\n      System.out.println(\"Tree transformed\");\n      Tree tree = transformer.transformTree(t);\n      tree.pennPrint();\n      System.out.println();\n      System.out.println(\"----------------------------\");\n    }\n  }\n\n}\n","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/QPTreeTransformer.java#L150-L186","documentation":"QPTreeTransformer.main loads trees from files given on the command line using PennTreeReader; any IOException while opening or reading those files is wrapped in this bare RuntimeException(\"File problem: \" + e), typically meaning the named tree file does not exist or cannot be read.","triggerScenarios":"Running QPTreeTransformer.main with a treeFileName argument that points to a nonexistent file, a directory, or a file without read permission, so new FileInputStream(...) throws FileNotFoundException/IOException.","commonSituations":"Typos in the path on the command line; running from a different working directory than expected; files moved after a corpus reorganization; missing read permissions.","solutions":["Verify the file path passed on the command line exists and is readable (ls -l <path>), fixing the path or running from the correct directory.","Use absolute paths or paths relative to the actual working directory when invoking the tool.","Check file permissions; chmod/read-access the tree file if needed.","Catch the RuntimeException in a wrapper script and validate files exist before invoking the tool."],"exampleFix":"// before\njava edu.stanford.nlp.trees.QPTreeTransformer wsj/0001/wsj_0101.mrg  // wrong cwd\n// after\njava edu.stanford.nlp.trees.QPTreeTransformer \"/data/ptb/wsj/00/wsj_0101.mrg\"  // verified existing absolute path","handlingStrategy":"validation","validationCode":"List<String> files = Arrays.asList(treeFileNames);\nfor (String name : files) {\n  File f = new File(name);\n  if (!f.isFile() || !f.canRead())\n    throw new IllegalArgumentException(\"Tree file not readable: \" + f.getAbsolutePath());\n}","typeGuard":null,"tryCatchPattern":"try {\n  QPTreeTransformer.main(args);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"File problem:\")) {\n    log.error(\"Bad tree file argument: \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Use absolute paths when invoking CLI tree tools from scripts or other directories.","Check existence/read permission of every argument file before running the tool.","Avoid spaces/typos in paths by building argument lists programmatically from directory scans."],"tags":["io","file-not-found","cli","treebank"],"backgroundTag":"file-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}