Thursday, May 13, 2010

org.geotools.data.jdbc.JDBCFeatureSource cannot be cast to org.geotools.data.FeatureStore

Using geotools 2.6.x, occurs an error in Postgis when a geo-table is not correctly structured for.

This error is thrown:

org.geotools.data.jdbc.JDBCFeatureSource cannot be cast to org.geotools.data.FeatureStore

To solve this, a table in POSTGIS always must have the GIST index, so a well formed table looks like as follows:


--drop table poi cascade;
create table poi(
pk_poi serial primary key,
name_poi varchar(10),
date_poi timestamp
);
SELECT AddGeometryColumn('', 'poi','the_geom',4326,'POINT',2);
CREATE INDEX poi_the_geom_gist
ON poi
USING gist
(the_geom);


problem solved!