{"record":{"id":"6b4b4e91351aade1","repo":"pentaho/pentaho-kettle","slug":"unable-to-read-from-dbf-file","errorCode":null,"errorMessage":"Unable to read from DBF file","messagePattern":"Unable to read from DBF file","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"plugins/shapefilereader/core/src/main/java/org/pentaho/di/shapefilereader/ShapeFileReaderMeta.java","lineNumber":233,"sourceCode":"\n      XBase xbase = new XBase( getLog(), dbFilename );\n      try {\n        xbase.setDbfFile( dbFilename );\n        xbase.open();\n\n        //Set encoding\n        if ( StringUtils.isNotBlank( encoding ) ) {\n          xbase.getReader().setCharactersetName( encoding );\n        }\n\n        RowMetaInterface fields = xbase.getFields();\n        for ( int i = 0; i < fields.size(); i++ ) {\n          fields.getValueMeta( i ).setOrigin( name );\n          row.addValueMeta( fields.getValueMeta( i ) );\n        }\n\n      } catch ( Throwable e ) {\n        throw new KettleStepException( \"Unable to read from DBF file\", e );\n      } finally {\n        xbase.close();\n      }\n    } else {\n      throw new KettleStepException( \"Unable to read from DBF file: no filename specfied\" );\n    }\n  }\n\n  public String getXML() {\n    String retval = \"\";\n\n    retval += \"    \" + XMLHandler.addTagValue( \"shapefilename\", shapeFilename );\n    retval += \"    \" + XMLHandler.addTagValue( \"dbffilename\", dbfFilename );\n    retval += \"    \" + XMLHandler.addTagValue( \"encoding\", encoding );\n\n    return retval;\n  }\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/shapefilereader/core/src/main/java/org/pentaho/di/shapefilereader/ShapeFileReaderMeta.java#L215-L251","documentation":"ShapeFileReaderMeta.getFields reads the DBF (attribute) file with an XBase reader to derive output row fields; any Throwable while opening/reading it is wrapped in 'Unable to read from DBF file'. It signals that the field layout could not be determined because the DBF file could not be accessed or parsed.","triggerScenarios":"getFields is called (e.g. during step preview or transformation layout resolution) and the XBase reader throws while opening or reading the .dbf at the configured dbfFilename — missing file, wrong path, corrupt header, or unsupported encoding.","commonSituations":"The .dbf path was moved or renamed, the shapefile was copied without its sidecar files, the file is locked by another process, or the file is not actually a dBase/DBF file.","solutions":["Verify the DBF filename field points to an existing, readable .dbf file that accompanies the .shp.","Copy all shapefile sidecar files (.shp, .shx, .dbf) together.","Check file permissions and that no other process holds an exclusive lock on the .dbf.","Inspect the wrapped cause 'e' in the stack trace for the precise I/O or parse failure."],"exampleFix":"// before\nString dbf = \"/data/roads.dbf\"; // file does not exist\n// after\nFile f = new File( \"/data/roads.dbf\" );\nif ( !f.exists() ) throw new KettleException( \"DBF missing: \" + f );\nString dbf = f.getAbsolutePath();","handlingStrategy":"validation","validationCode":"File dbf = new File( dbfFilename );\nif ( !dbf.isFile() || !dbf.canRead() ) {\n  throw new KettleException( \"DBF file missing or unreadable: \" + dbfFilename );\n}","typeGuard":null,"tryCatchPattern":"try {\n  meta.getFields( row, name, info, null, null, repository );\n} catch ( KettleStepException e ) {\n  logError( \"DBF read failed: \" + e.getCause(), e );\n}","preventionTips":["Always move .shp/.shx/.dbf files together as a set.","Check file permissions and locks before running the transformation.","Use absolute paths for the DBF filename in shared environments."],"tags":["dbf","file-io","shapefile","kettle"],"backgroundTag":"file-read-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"}