pentaho/pentaho-kettle · error · ContentCreationException
File already exists.
Error message
File already exists.
What it means
FileObjectContentLocation.createLocation(name) creates a sub-location; if the resolved child file object already exists it throws ContentCreationException 'File already exists.' instead of overwriting or returning the existing location.
Solutions
- Check existence first (getLocation(name) or exists) and reuse the existing location instead of creating.
- Delete the existing location if a fresh directory is required.
- Generate unique location names per run (timestamp/run-id).
- Synchronize creation across concurrent workers.
Example fix
// before
ContentLocation sub = location.createLocation("exports");
// after
ContentLocation sub = location.getLocation("exports");
if (sub == null) {
sub = location.createLocation("exports");
} Defensive patterns
Strategy: validation
Validate before calling
ContentLocation existing = location.getLocation(name); // null when absent boolean exists = existing != null;
Try / catch
try {
sub = location.createLocation(name);
} catch (ContentCreationException e) {
if (e.getMessage().equals("File already exists.")) sub = location.getLocation(name);
} Prevention
- Prefer getLocation() and create only when null.
- Use run-specific directory names.
- Clean leftovers from failed runs at job start.
When it happens
Trigger: Calling createLocation(name) where file.resolveFile(name).exists() is true.
Common situations: Re-running a reporting job that creates the same sub-directory each run; concurrent jobs both attempting to create the same location; leftover artifacts from a previous failed run.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- File already exists:
- Failed to create the content-location
- Not File nor directory.
- AbstractFileErrorHandler.Exception.CouldNotCreateFileErrorHandlerForFile
- Append file in repository is not possible
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/72f3ea4ce8df92c4.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/pentaho-reporting/impl/src/main/java/org/pentaho/di/trans/steps/pentahoreporting/urlrepository/FileObjectContentLocation.java:189
}
/**
* Creates a new content location in the current location. This method must never return null. This method will fail
* if an entity with the same name exists in this location.
*
* @param name the name of the new entity.
* @return the newly created entity, never null.
* @throws ContentCreationException if the item could not be created.
*/
public ContentLocation createLocation( final String name ) throws ContentCreationException {
if ( RepositoryUtilities.isInvalidPathName( name ) ) {
throw new IllegalArgumentException( "The name given is not valid." );
}
try {
final FileObject file = getBackend();
final FileObject child = file.resolveFile( name );
if ( child.exists() ) {
throw new ContentCreationException( "File already exists." );
}
child.createFile();
try {
return new FileObjectContentLocation( this, child );
} catch ( ContentIOException e ) {
throw new ContentCreationException( "Failed to create the content-location", e );
}
} catch ( FileSystemException e ) {
throw new RuntimeException( e );
}
}
/**
* Checks, whether an content entity with the given name exists in this content location. This method will report
* invalid filenames as non-existent.
*
* @param name the name of the new entity.
* @return true, if an entity exists with this name, false otherwise.View on GitHub (pinned to f3058517a1)