{"record":{"id":"47535b898cde6181","repo":"pentaho/pentaho-kettle","slug":"exporting-jobs-couldn-t-create-file-filename","errorCode":null,"errorMessage":"Exporting jobs: Couldn't create file [${filename}]","messagePattern":"Exporting jobs: Couldn't create file \\[(.+?)\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/repository/dialog/RepositoryExplorerDialog.java","lineNumber":2682,"sourceCode":"            dir.mkdir();\n            log.logBasic( \"Exporting Jobs\", \"Created directory [\" + dir.getName() + \"]\" );\n          }\n\n          for ( int i = 0; i < jobs.length; i++ ) {\n            JobMeta ji = rep.loadJob( jobs[i], repdir, null, null ); // reads last version\n            log.logBasic( \"Exporting Jobs\", \"[\" + jobs[i] + \"] in directory [\" + repdir.getPath() + \"]\" );\n\n            String xml = XMLHandler.getXMLHeader() + ji.getXML();\n\n            String filename =\n              directory + repdir.getPath() + Const.FILE_SEPARATOR + fixFileName( jobs[i] ) + \".kjb\";\n            File f = new File( filename );\n            try {\n              FileOutputStream fos = new FileOutputStream( f );\n              fos.write( xml.getBytes( Const.XML_ENCODING ) );\n              fos.close();\n            } catch ( IOException e ) {\n              throw new RuntimeException( \"Exporting jobs: Couldn't create file [\" + filename + \"]\", e );\n            }\n          }\n        }\n      }\n    } catch ( Exception e ) {\n      new ErrorDialog( shell,\n        BaseMessages.getString( PKG, \"RepositoryExplorerDialog.ExportJobs.UnexpectedError.Title\" ),\n        BaseMessages.getString( PKG, \"RepositoryExplorerDialog.ExportJobs.UnexpectedError.Message\" ), e );\n    }\n  }\n\n  public void exportAll( RepositoryDirectoryInterface dir ) {\n    FileDialog dialog = Spoon.getInstance().getExportFileDialog(); // new FileDialog( shell, SWT.SAVE | SWT.SINGLE );\n    if ( dialog.open() == null ) {\n      return;\n    }\n\n    String filename = dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName();","sourceCodeStart":2664,"sourceCodeEnd":2700,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/repository/dialog/RepositoryExplorerDialog.java#L2664-L2700","documentation":"When exporting a job from the repository explorer, the XML is written with FileOutputStream. An IOException during file creation or writing is rethrown as RuntimeException 'Exporting jobs: Couldn't create file [filename]'. The target job export file could not be created.","triggerScenarios":"Exporting a job to a path with a missing parent directory, no write permission, a directory already at that path, or a full disk.","commonSituations":"Export destination on a read-only or disconnected network share; unresolved ${filename} variable; filename with characters invalid on the OS; insufficient privileges of the PDI process.","solutions":["Ensure the destination directory exists and is writable before exporting","Use an absolute, variable-resolved path for the export filename","Check disk space and file locks, then retry","Read the wrapped IOException cause to identify the exact OS failure"],"exampleFix":"// before\nexportJob(\"/mnt/ro-share/job.kjb\");\n// after\nFile out = new File(System.getProperty(\"user.home\"), \"job.kjb\");\nif (!out.getParentFile().canWrite()) { showError(\"Cannot write to \" + out.getParent()); return; }\nexportJob(out.getAbsolutePath());","handlingStrategy":"validation","validationCode":"File f = new File(filename);\nFile parent = f.getParentFile();\nif (parent == null || !parent.canWrite()) throw new IllegalStateException(\"Cannot write to \" + parent);","typeGuard":null,"tryCatchPattern":"try { exportJob(filename); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Exporting jobs\")) { showError(\"File creation failed for \" + filename + \": \" + e.getCause()); } else { throw e; } }","preventionTips":["Use absolute, already-resolved paths for job exports","Verify disk space and write permissions before exporting","Keep export destinations on local writable storage","Check e.getCause() (IOException) to pinpoint the failure"],"tags":["io","file-write","export","kettle"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}