pentaho/pentaho-kettle · error · KettleException

We can not find folder

Error message

We can not find folder [{0}]! You need to create it before generating file [{1}].

What it means

When 'create parent folder' is enabled, the step checks the target file's parent folder and creates it if missing. If the folder does not exist and cannot be created, it throws KettleException 'We can not find folder [...]! You need to create it before generating file [...]'.

Solutions

  1. Manually create the missing output directory before running the transformation
  2. Enable 'Create parent folder' in the step and ensure the connecting user has write permission on the parent path
  3. Verify the substituted filename/path resolves to a valid location

Example fix

// before: dir missing
// shell: mkdir -p /output/daily || fail
// after
new File( "/output/daily" ).mkdirs(); // or enable meta.setCreateParentFolder( true );
Defensive patterns

Strategy: validation

Validate before calling

File parent = new File( variableSubstitute( filename ) ).getAbsoluteFile().getParentFile();
if ( !parent.exists() && !parent.mkdirs() ) throw new IllegalStateException( "Cannot create folder: " + parent );

Type guard

boolean parentFolderReady( String filename ) { File p = new File( filename ).getAbsoluteFile().getParentFile(); return p != null && ( p.isDirectory() || p.mkdirs() ); }

Try / catch

try { openNewFile(); } catch ( KettleException e ) { if ( e.getMessage().contains( "can not find folder" ) ) { ensureFolderExists(); retryOpen(); } else throw e; }

Prevention

When it happens

Trigger: Parent folder resolution succeeds but the folder is absent and parentfolder.createFolder() fails or is not attempted (e.g. create-parent-folder not enabled), leaving folder==null/not existing at write time.

Common situations: Directory deleted between planning and run; permission denied preventing creation; variable substitution produced a bad path; running as user without write access to the parent directory.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/542904e00a8fb865. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java:1003

      parentfolder = getFileObject( filename, getTransMeta() ).getParent();
      if ( parentfolder.exists() ) {
        if ( isDetailed() ) {
          logDetailed( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderExist",
              KettleVFS.getFriendlyURI( parentfolder ) ) );
        }
      } else {
        if ( isDetailed() ) {
          logDetailed( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderNotExist",
              KettleVFS.getFriendlyURI( parentfolder ) ) );
        }
        if ( meta.isCreateParentFolder() ) {
          parentfolder.createFolder();
          if ( isDetailed() ) {
            logDetailed( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderCreated",
                KettleVFS.getFriendlyURI( parentfolder ) ) );
          }
        } else {
          throw new KettleException( BaseMessages.getString( PKG, "TextFileOutput.Log.ParentFolderNotExistCreateIt",
            KettleVFS.getFriendlyURI( parentfolder ),
            KettleVFS.getInstance( getTransMeta().getBowl() ).getFriendlyURI( filename ) ) );
        }
      }
    } finally {
      if ( parentfolder != null ) {
        try {
          parentfolder.close();
        } catch ( Exception ex ) {
          // Ignore
        }
      }
    }
  }



  /**

View on GitHub (pinned to f3058517a1)