pentaho/pentaho-kettle · error · GisException
Error reading shape file
Error message
Error reading shape file
What it means
ShapeFile.readFile wraps any IOException from reading the .shp stream or the XBase DBF rows into a GisException 'Error reading shape file'. It is a generic I/O failure while walking shape records, after the file was opened successfully.
Solutions
- Verify the .shp file size against the length recorded in its 100-byte main header; re-download/re-copy if truncated.
- Ensure .shp and .dbf record counts match (use a shapefile validator such as shpcheck or ogrinfo).
- Copy the shapefile set to local disk instead of reading over the network.
- Check the wrapped IOException cause for the exact read failure.
Example fix
// before FileInputStream in = new FileInputStream( "/mnt/net/data.shp" ); // network drop mid-read // after File local = new File( "/tmp/data.shp" ); Files.copy( Paths.get( "/mnt/net/data.shp" ), local.toPath() ); // full local copy first FileInputStream in = new FileInputStream( local );
Defensive patterns
Strategy: validation
Validate before calling
File shp = new File( path );
try ( RandomAccessFile raf = new RandomAccessFile( shp, "r" ) ) {
byte[] h = new byte[100]; raf.readFully( h );
long expected = Integer.reverseBytes( ByteBuffer.wrap( h ).getInt( 24 ) ) * 2L;
if ( shp.length() < expected ) throw new IllegalStateException( ".shp truncated: " + shp.length() + " < " + expected );
} Try / catch
try {
shapeFile.readFile();
} catch ( GisException e ) {
if ( e.getCause() instanceof IOException ) {
log.error( "I/O failure reading shapefile, re-fetch the file", e );
}
} Prevention
- Verify file integrity (size vs header-declared length) before reading.
- Copy shapefiles from network shares to local disk first.
- Keep .shp and .dbf record counts in sync; validate with ogrinfo.
When it happens
Trigger: The DataInputStream over the .shp hits EOF early (truncated file), a disk/network read fails, or xbase.getRow throws an IOException while pairing DBF rows with shapes.
Common situations: Incomplete downloads/copies of the .shp, files with mismatched .shp/.dbf record counts, network-mounted shapefiles with dropped connections, or corrupt headers claiming more bytes than exist.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- AvroInput.Error.ObjectReadError
- Could not read file
- JobSQL.ErrorRunningSQLfromFile
- shape type : not recognized! ( )
- throw new KettleException( e );
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/96b232d3c0752387.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/shapefilereader/core/src/main/java/org/pentaho/gis/shapefiles/ShapeFile.java:158
throw new GisException( "shape type : " + btype + " not recognized! (" + Shape.getEsriTypeDesc( btype ) + ")" );
}
// Get a row from the associated DBF file...
Object[] row = xbase.getRow( fields );
if ( row != null ) {
esi.setDbfData( row );
esi.setDbfMeta( xbase.getFields() );
}
shapes.add( esi );
id++;
}
}
dis.close();
xbase.close();
} catch ( IOException e ) {
throw new GisException( "Error reading shape file", e );
}
}
public int getNrShapes() {
return shapes.size();
}
public ShapeInterface getShape( int i ) {
return shapes.get( i );
}
public void addShape( ShapeInterface esi ) {
shapes.add( esi );
}
public ShapeFileHeader getFileHeader() {
return fileheader;
}View on GitHub (pinned to f3058517a1)